In What lines will this code fail (meaning: don’t do what they are supposed to do), and why?
int main(void) {
char student[64] = "some guy";
char* teacher;
/* line1 */ strcpy(teacher, student);
/* line2 */ teacher=student;
/* line3 */ strcpy(student, "Alber Einstein");
/* line4 */ student = teacher;
}
Line 1 causes undefined behaviour. Line 4 won’t even compile. Since this seems like it could just as easily be a homework question, and I don’t like to give the whole thing away, a quick read of the comp.lang.c FAQ or the C language specification will explain why.