Upload
clark-alston
View
27
Download
0
Embed Size (px)
DESCRIPTION
CSC 253. Lecture 13. 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 - PowerPoint PPT Presentation
Citation preview
CSC 253CSC 253
Lecture 13Lecture 13
SyntaxSyntax
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?
a. To declare two addrEntry structuresb. To declare two synonyms for the same typec. To declare synonyms for two slightly different typesd. To assign the same value to two different variables
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?
a. To declare two addrEntry structuresb. To declare two synonyms for the same typec. To declare synonyms for two slightly different typesd. To assign the same value to two different variables
Consider the main program …
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?
a. Creating two address nodes and linking them togetherb. Creating two address nodes that are not linked togetherc. Creating one address node that is known by two names
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?
a. Creating two address nodes and linking them togetherb. Creating two address nodes that are not linked togetherc. Creating one address node that is known by two names
Let’s read values into our nodes …
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?a. Locations 1, 2, and 3b. Locations 1 and 3c. Locations 1 and 2d. Locations 1, 2, 3, and 4e. Locations 1, 2, 3, 4, and 5
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?a. Locations 1, 2, and 3b. Locations 1 and 3c. Locations 1 and 2d. Locations 1, 2, 3, and 4e. Locations 1, 2, 3, 4, and 5
Let’s run the code & read in values
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?
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?
Let’s make the code for printing less repetitiveLet’s make the code for printing less repetitive
Define a printField(…) function. How many places can we call it?
Define a printField(…) function. How many places can we call it?
Field-referencing notationField-referencing notation
Which of the following mean the same thing as myAddress->name?a. myAddress.name
b. *myAddress.name
c. (*myAddress).name
d. b and ce. None of the above
Which of the following mean the same thing as myAddress->name?a. myAddress.name
b. *myAddress.name
c. (*myAddress).name
d. b and ce. None of the above