I have a set of questions that may be asked for my exams. Can anyone tell me the solutions to this?
Q1)
I know it is a segmentation fault, but why"?Code:What is the problem with the following copy? char *s1 = “hello”; char *s2; strcpy(s2,s1);
Q2)
What are the two common problems of working with dynamic memory
allocation and pointers?
Q3)
Explain top-down and bottom-up debugging techniques.
Q4)
Assume function static void f(void) whose definition is in body.c
and its prototype is in body.h. If I include body.h in another C file, myprog.c,
having the main function and calls function f, and try to run gcc body.c
myprog.c –o myprog, should I expect any error message (assume that all
programs are syntactically correct)? If yes, the error belongs to which step of
compilation (i.e. preprocessing, linking, etc.)? Why?
I know there will be an error. But why?
Pleas reply.