hi all
i am getting the segmentation fault when i try to execute the code mentioned below. is there any specific in the storage of string literal that is causing this ?
can anybody explain me the reason and how the constants are alloted memory ?
thanks in advance
sanjay
i am getting the segmentation fault when i try to execute the code mentioned below. is there any specific in the storage of string literal that is causing this ?
Code:
char *str1;
str1=(char *) malloc (100);
str1="hello";
cout<<str1;
free(str1);
cout<<str1;
return 0;
can anybody explain me the reason and how the constants are alloted memory ?
thanks in advance
sanjay