Discussion
For the following code snippet:
char *str = "AllIndiaExams.in\0" "training classes";
The character pointer str holds reference to string:
Answer: C
Correct answer: AllIndiaExams.in\0training classes
Adjacent string literals are concatenated at translation time, so "AllIndiaExams.in\0" and "training classes" become a single literal. The embedded \0 is retained as a byte within it, and the compiler still appends its own terminating null at the very end.
The pointer therefore refers to the whole of that storage. Printing it with %s would show only AllIndiaExams.in, because printf stops at the first null - but what str holds a reference to is the complete concatenated sequence, which is what the question asks.
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