C - Functions - Discussion

You Are Here :: Home > C > Functions - Discussion

 



Q.

What will be the output of the following code segment, if any?

myfunc ( struct test t) {
strcpy(t.s, "world");
}
main( ) {
struct test { char s[10]; } t;
strcpy(t.s, "Hello");
printf("%s", t.s);
myfunc(t);
printf("%s", t.s);
}

A. Hello Hello B. world world
C. Hello world D. the program will not compile

Answer: Option D
Explaination:

The program will not compile because undefined symbol s for myfunc( ) function. Structure should be defined before the main and the function where it is called.



Discussion

Your Comments Goes here...
NameDiscussion