+ 1
Where does the "Hii" String present in the below code actually get stored? Whether in Heap or stack memory?
In that code,pointer value(String address) stored in stack, but where does the string actually get stored? In pythontutor -code visualiser website, it shows those strings get stored in "read only storage not heap". I really don't understand what is "read only storage " is it means Read only memory (ROM).âŠ..? https://sololearn.com/compiler-playground/cYyX8lCW9BHZ/?ref=app
3 Answers
+ 1
Yes, you are right. To clarify, it is not stored in ROM, which is a type of hardware storage chip that holds permanently burned in code for firmware or bootstrap code. The Data segment is in RAM, and the read-only behavior is enforced merely as a run-time convention.
+ 1
There is a Program Data segment of memory that holds all the program literals. The Data segment gets filled in by the OS's program loader as it reads the executable file into memory. It is treated as a read-only segment. Should you try to write to the string you will get a 'segment violation' run-time error.
0
Is those string literal get stored in code/text segment? Am I right