I understand this is safe...
const char *get_str_literal() {
return "I literally can't even";
}
But is this?
const char *get_str_literal() {
const char *str = "I literally can't even";
return str;
}
If not, why?
Edit: How does the below snipped differ from the second code snippet above?
const char *get_str_literal() {
const char str[] = "I literally can't even";
return str;
}
Does the string literal's contents get copied into automatic array storage? What happens?
const char str[]
) versus a pointer results in issues? Would the array assignment be automatic storage? – Diplococcus