+ 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

17th Feb 2024, 2:42 AM
Yogeshwaran P
Yogeshwaran P - avatar
3 Respostas
+ 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.
17th Feb 2024, 10:35 AM
Brian
Brian - avatar
+ 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.
17th Feb 2024, 6:59 AM
Brian
Brian - avatar
0
Is those string literal get stored in code/text segment? Am I right
17th Feb 2024, 8:08 AM
Yogeshwaran P
Yogeshwaran P - avatar