As per my understanding, Data Segment consists of 2 parts.
1. Initialized segment.
a. Read Only.
b. Read/Write.
2. Uninitialized segment.
- The Read/Write memory is for variables declared at file scope as well as static local variables.
- The Read only memory is for constants such as strings.
Example:
int main(void)
{
char* cptr = "Hello"; // The string "Hello" will sit in 'Read only' memory.
//cptr[2] = 'Z'; // Gives seg fault.
...
return 0;
}
My question is, Is 'Read-only' memory only used to store string constants?