first code
second code
I guess the first code invokes UB because a is a local variable which will be destroyed after the function exits and accessing it in main invokes UB.
want to know if the second one also invokes UB??
Code:
char * f(void){
char a[]="C is a very good language";
return a;
}
int main()
{
char* b= f();
printf("%s",b);
getchar();
}
Code:
int f(void){
int x=9;
return x;
}
int main()
{
int i=f();
printf("%d",i);
getchar();
}
want to know if the second one also invokes UB??
Comment