Consider this function:
void useless() {
char data[] = "aaa";
}
From what I learned here, the "aaa"
literal lives to the end of the program. However, the data[]
(initialized by the literal) is local, so it lives only to the end of the function.
The memory is copied, so the program needs 4B for the literal, 4B for the data
and sizeof(size_t)
bytes for the pointer to data
and sizeof(size_t)
for the pointer of the literal - is this true?
If the literal has static storage duration, no new memory is allocated for the local literal by the second call - is this true?