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

Discussion

Which of the following declaration is illegal?

  • A.char *str = “Best C programming classes by AllIndiaExams”;
  • B.char str[] = “Best C programming classes by AllIndiaExams”;
  • C.char str[20] = “Best C programming classes by AllIndiaExams”;
  • D.char[] str = “Best C programming classes by AllIndiaExams”;

Answer: D

Correct answer: char[] str = “...”;

C writes the brackets after the identifier, not after the type: char str[]. The form with the brackets before the name belongs to Java. The other three are all valid ways of holding a string, though the third truncates if the literal exceeds the declared size.

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

Post your comment

Please log in or register to post a comment.