-
one doubt in C Quiz
I am having doubt in one question in C quiz.
How is a structure variable named as test declared for a structure named as struct exforsys?
My answer was struct exforsys test; and system's answer was exforsys test;
in gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) , if you do not used #typedef then u need to write struct before any structure.
Can anyone can clearify it.
-
Re: one doubt in C Quiz
As per my views,
as the structure type variable exforsys has been already defined as a structure variable so it doesnt needs to define it again for creating its own variable...
-
Re: one doubt in C Quiz
it can only be done if exforsys is already defined as a structure thn no need to define it as struct again.
-
Re: one doubt in C Quiz
[QUOTE=Avaited;14508]I am having doubt in one question in C quiz.
How is a structure variable named as test declared for a structure named as struct exforsys?
My answer was struct exforsys test; and system's answer was exforsys test;
in gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) , if you do not used #typedef then u need to write struct before any structure.
Can anyone can clearify it.[/QUOTE]
With the details you have given, you are absolutely right in that without a typedef, there is no way that we can skip the struct in most C compilers. Infact, even if the fancy compiler allowed you to do that, the compiler has to be backward compatible with standard C programming conventions and thus your answer cannot be wrong.
-
Re: one doubt in C Quiz
[quote=avaited;14508]i am having doubt in one question in c quiz. How is a structure variable named as test declared for a structure named as struct exforsys? my answer was struct exforsys test; and system's answer was exforsys test; in gcc (gcc) 3.4.3 20041212 (red hat 3.4.3-9.el4) , if you do not used #typedef then u need to write struct before any structure. Can anyone can clearify it.[/quote] ans:- i know ur dout, its very common. To clear ur dout read yashwant kanetkar...