In C, what is the difference in memory allocation between character arrays and string literals?

  • Character arrays are automatically null-terminated, while string literals are not.
  • Character arrays are stored in read-write memory, while string literals are stored in read-only memory.
  • Character arrays cannot be used as function arguments, while string literals can.
  • String literals are stored in read-write memory, while character arrays are stored in read-only memory.
Character arrays in C are typically stored in read-write memory, allowing you to modify their contents. In contrast, string literals are stored in read-only memory, making them immutable. This difference in memory allocation is essential for understanding how to work with strings in C.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *