Hi,
I had sort of a noob question on memory allocation for strings.
char *str1 = "Hello World!";
char str2[] = "Hello World!";
In the above bit are both str1 & str2 stack allocated or heap allocated
or otherwise? Also, unless explicitly malloc'ing a string buffer are we
not required to free it? Or are there other circumstances in which we
are required to free?
Hope to hear from someone out there.
Thanks.
DJP
I had sort of a noob question on memory allocation for strings.
char *str1 = "Hello World!";
char str2[] = "Hello World!";
In the above bit are both str1 & str2 stack allocated or heap allocated
or otherwise? Also, unless explicitly malloc'ing a string buffer are we
not required to free it? Or are there other circumstances in which we
are required to free?
Hope to hear from someone out there.
Thanks.
DJP
Comment