1

When I use char pointer to a string as:

char *a = "Hello";

will the C run-time library create a memory spape for that string? If it does, where is the string "Hello" allocated, in the heap or in the stack?

Jongware
  • 22,200
  • 8
  • 54
  • 100
Yun-Lung Lee
  • 105
  • 4
  • You can think of it as being allocated in the same place that a read-only (ie, `const`) global variable would reside. – jxh Aug 24 '14 at 13:53
  • I got it!!! So the string will be put in data section at compiler time ?? – Yun-Lung Lee Aug 24 '14 at 14:01
  • You should see it somewhere in the compiled object or executable, and it will be designated for a particular section. – jxh Aug 24 '14 at 14:42

0 Answers0