S
Senthilraja
I am able to compile the following code and get "hello" as ouput
everytime I execute it:-
#include <stdio.h>
int main (void)
{
char *str;
str="hello";
puts(str);
return 0;
}
Before assigning the string constant "hello" to str, str in this case
doesn't points to a valid memory location (it points to nowhere). I
guess it is not correct to do this assignment, but it produces right
output eveytime. Is the compiler allocating necessary memory by itself,
automatically? If yes, where is this memeory; in stack or the heap or ??
everytime I execute it:-
#include <stdio.h>
int main (void)
{
char *str;
str="hello";
puts(str);
return 0;
}
Before assigning the string constant "hello" to str, str in this case
doesn't points to a valid memory location (it points to nowhere). I
guess it is not correct to do this assignment, but it produces right
output eveytime. Is the compiler allocating necessary memory by itself,
automatically? If yes, where is this memeory; in stack or the heap or ??