Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 253 Lecture 13.

Similar presentations


Presentation on theme: "CSC 253 Lecture 13."— Presentation transcript:

1 CSC 253 Lecture 13

2 Syntax In the lecture, Jason defined a typedef
typedef struct addrEntry { char* name; … struct addrEntry *next; } AddrT, *AddrTP What is the purpose of the last line? To declare two addrEntry structures To declare two synonyms for the same type To declare synonyms for two slightly different types To assign the same value to two different variables

3 Consider the main program …
int main(){ AddrT myAddressList=createBlank(); AddrT temp=createBlank(); myAddressList.next=&temp; printAddr(&myAddressList); deleteAddr(temp); myAddressList.next=NULL; deleteAddr(myAddressList); } What is the code doing? Creating two address nodes and linking them together Creating two address nodes that are not linked together Creating one address node that is known by two names

4 Let’s read values into our nodes …
In the following code, … char1 readLine(FILE2 file) { int i; char3 line; if ((line = malloc(256*sizeof(char))) == NULL) return EXIT_FAILURE; return fgets(line4, 256, file5); } where should there be asterisks? Locations 1, 2, and 3 Locations 1 and 3 Locations 1 and 2 Locations 1, 2, 3, and 4 Locations 1, 2, 3, 4, and 5

5 Let’s run the code & read in values
How do we call this function from the main program? When we run the program, what will be the ID numbers of the two nodes? Why is there a blank line between every two lines of output?

6 Let’s make the code for printing less repetitive
Define a printField(…) function. How many places can we call it?

7 Field-referencing notation
Which of the following mean the same thing as myAddress->name? myAddress.name *myAddress.name (*myAddress).name b and c None of the above


Download ppt "CSC 253 Lecture 13."

Similar presentations


Ads by Google