CS 61C (Fall 2007)

Quiz 4

One question, submit as "quiz4".  Due 2:45pm before lecture 9/7/2007.


To be very clear, you should submit one and only one file template.txt which contains your answers, by running submit quiz4.
Any files not named template.txt will be ignored, without exception!


1.

Consider the following complete program (this is the entirety of the program, there are no other lines in this file).
1 ) struct point {
2 )     int x;
3 )     int y;
4 ) };
5 ) 
6 ) struct point* scanpoint() {
7 )     struct point *temp = new point;
8 )     scanf("%d %d", &(temp->x), &(temp->y));
9 )     return temp;
10) }
11) 
12) void main() {
13)     struct point p = scanpoint();
14)     printf("%d %d", p->x, p->y);
15) }

There are 4 simple bugs in this program, list the line numbers (separated by commas) on which they occur. If a line is missing, use a non-integer (e.g. 10.5 would mean there is a line missing between lines 10 and 11, 0 or -1 would mean a line must be added at the beginning).

For each bug, very briefly explain the problem, a few words or short sentence will suffice.

Note that we have not asked you to fix the bugs, nor have we asked to list all the changes you would need to make this code work (there are more than 4). We just asked you where the bugs are in the current code. The questions are different: we asked you where the problems are, not to produce working code.