PRELAB #8 RUBRIC: 1.a.) S can store a fixed number of items of different types A can store an arbitrarily large number of items of the same type 1 pt: S items can have different types 1 pt: A items are of the same type 1 pt: the number of S items is fixed 1 pt: the number of A items is variable (the specific explanations can be variable, so use your best judgement) 1.b.) 2 pts: For arrays, you use a subscript with square brackets (A[ subscript ]) 2 pts: For structs, you use the "dot" operator (S.field) (the specific explanations can be variable, so use your best judgement) 2.) struct book { char title[ 50 ]; int year; int pages; }; 1 pt: struct book 1 pt: char title[ some subscript ]; 1 pt: the subscript used for title is 50 (no book title contains a null byte, but C strings must end with a null byte) 1 pt: int year 1 pt: int pages 2 pts: syntax (including the terminating semicolon) 1 pt: if the syntax is correct but they forgot the terminating semicolon 3.a.) 3 pts: struct book cs16text; -Do not take off points if they forgot the terminating semicolon -Do not take off if they initialized it as well -Anything else receives no credit 3.b.) strcpy( cs16text.title, s ); 1 pt:strcpy is used 2 pts: the first parameter is cs16text.title 1 pt: cs16text->title 1 pt: the second parameter is s 1 pt: syntax is correct (do not take off if terminating semicolon is missing) 3.c.) 2 pts: cs16text.year = 2005; -1 pt: cs16text->year = 2005 2 pts: cs16text.pages = 448; 1 pt: cs16text->pages = 448; Do not take off if the semicolons are missing 4.a.) s is a copy of temp. When s.year is set, it modifies only the copy, not the original temp. 2 pts: It's mentioned (somehow) that a copy is made (use your best judgement) 2 pts: It's mentioned (somehow) that only the copy is manipulated (use your best judgement) 4.b.) s points directly to temp. When we do s->year, it dereferences to temp, and temp is modified directly. Another full credit answer: No copy of temp is made, and we manipulate only the original temp though s. Any full credit answer will somehow state that s refers directly to temp. Use your best judgement. 5.) void printBook( struct book* b ) { printf( "%s\n", b->title ); printf( "published %i\n", b->year ); printf( "%i pages\n", b->pages ); } 1 pt: return type is void 2 pts: takes a struct book* -1 pt: it takes a struct book (no pointer) 2 pts: The title is accessed in the struct -1 pt: it is attempted to be accessed via b.title. Take off even if they redefined the function to take a struct directly (but note that it's only because it's not working with a pointer.) 2 pts: The year is accessed in the struct -1 pt: it is attempted to be accessed via b.year. Take off even if they redefined the function to take a struct directly (but note that it's only because it's not working with a pointer.) 2 pts: The pages is accessed in the struct -1 pt: it is attempted to be accessed via b.pages. Take off even if they redefined the function to take a struct directly (but note that it's only because it's not working with a pointer.)