Question: Consider the following two C files main.C: #include int foo(int); int main(void) printf (%p , printf (%d , return (0); foo); foo(1)); 00.c: static int

 Consider the following two C files main.C: #include int foo(int); int

Consider the following two C files main.C: #include int foo(int); int main(void) printf ("%p ", printf ("%d ", return (0); foo); foo(1)); 00.c: static int func(int x) return (x + 1); int (*foo) (int) -func; The following commands are run in the directory that contains these two C files % clang -Wall -Wextra -c main.c % Clang -Wall -Wextra-c foo.c % clang -o foo main.o foo.o Segmentation fault (core dumped) Answer the following questions (a) Why are there no compiler errors or warnings when main.c is compiled? (b) Why are there no linker errors when the object files are linked? (c) Why does a segmentation fault occur when the program is run

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!