I have this code:
#include <iostream>
const char* out;
void f() {
const char* in = "foo";
out = in;
}
int main(){
f();
std::cout << out;
}
I'd like to know whether using out in std::cout << out; is undefined behavior.
In const char* in = "foo";, the literal "foo" is a object? I mean, when the expression is evaluated, an object is created to represent "foo"? If not, the in pointer points to the program's image? How lifetime works here for "foo" and in?