Am looking at the following program and not sure how the memory is allocated and why:
void function() {
char text1[] = "SomeText";
const char* text2 = "Some Text";
char *text = (char*) malloc(strlen("Some Text") + 1 );
}
In the above code, the last one is obviously in the heap. However, as I understand text2 is in the data segment of the program and text1 may be on the stack. Or is my assumption wrong? What is the right assumption here? Is this compiler dependent?
1 Answer