Results 1 to 5 of 5

Thread: one doubt in C Quiz

  1. #1
    Junior Member
    Join Date
    Nov 2005
    Answers
    1

    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.


  2. #2
    Junior Member
    Join Date
    Dec 2007
    Answers
    1

    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...


  3. #3
    Junior Member
    Join Date
    Dec 2007
    Answers
    2

    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.


  4. #4
    Contributing Member
    Join Date
    Dec 2007
    Answers
    46

    Re: one doubt in C Quiz

    Quote Originally Posted by Avaited View Post
    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.
    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.


  5. #5

    Re: one doubt in C Quiz

    Quote Originally Posted by avaited View Post
    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.
    ans:- i know ur dout, its very common. To clear ur dout read yashwant kanetkar...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact