C - Structures,Unions - Discussion

You Are Here :: Home > C > Structures,Unions - Discussion

 



Q.

struct list {

char *item;
struct list *next;
}
/* Here is the main program. */
main(argc, argv)
{ ... }

A. This program doesn't works correctly, but it dumps code after it finishes. B. This program works correctly, but it dumps code after it finishes.
C. output can't be predicted D. None of these

Answer: Option B
Explaination:

A missing semicolon causes main() to be declared as returning a structure. (The connection is hard to see because of the intervening comment.) Since structure-valued functions are usually implemented by adding a hidden return pointer, the generated code for main() tries to accept three arguments, although only two are passed (in this case, by the C start-up code).



Discussion

Your Comments Goes here...
NameDiscussion