M
mail1779205
I (certainly) hope I know what this function does:
char *fun(void){
char *ptr = "Hello World";
return ptr;
}
It returns a pointer to a string stored somewhere in the memory and is
read-only. Does the following function do the same thing and is the
code legal at all, that is, is the pointer
initialised to point to some string that is read-only?
char *fun(void){
char *ptr;
ptr = "Hello World";
return ptr;
}
I have looked in the FAQ, apologising if it's there somewhere. BTW,
Steve Summit thanks for this very useful resource.
Jesper
char *fun(void){
char *ptr = "Hello World";
return ptr;
}
It returns a pointer to a string stored somewhere in the memory and is
read-only. Does the following function do the same thing and is the
code legal at all, that is, is the pointer
initialised to point to some string that is read-only?
char *fun(void){
char *ptr;
ptr = "Hello World";
return ptr;
}
I have looked in the FAQ, apologising if it's there somewhere. BTW,
Steve Summit thanks for this very useful resource.
Jesper