Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following is a properly defined struct?

  • A.struct {int a;}
  • B.struct a_struct {int a;}
  • C.struct a_struct int a;
  • D.struct a_struct {int a;};

Answer: D

Correct answer: struct a_struct {int a;};

A structure definition is a declaration and must end with a semicolon - which is what the others omit. (The first form, without a tag, is legal if a variable is declared with it, but as written it declares nothing and is useless.)

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.