Discussion
Which option should be selected to work the following C expression?
string p = "HELLO";
Answer: B
Correct answer: typedef char *string;
A string in C is a pointer to its first character, so the alias must be a pointer type: typedef char *string; lets string p = "HELLO"; assign the literal’s address to p. The array form is not merely wrong syntax - even typedef char string[]; would give an incomplete type that cannot be initialised this way.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development