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

Discussion

In which memory segment are string literals typically stored in a C program ?

  • A.The stack
  • B.The heap
  • C.The read-only data segment
  • D.The uninitialised data segment

Answer: C

Correct answer: The read-only data segment

String literals are placed in a read-only area loaded with the program image. Attempting to modify one through a char pointer compiles but produces undefined behaviour, usually a segmentation fault.

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

Post your comment

Please log in or register to post a comment.