Possible Duplicate:
Why do I get a segmentation fault when writing to a string?
I was writing a simple string function. The problem is: I declare a char pointer, then once I try to update a specific character, the program crashes.
I have checked some previously written string processing, I found that they modify specific characters. But when I try to run them, I get the same problem.
Sample:
stringprocess()
{
char *s;
s=" I am c programmer";
s=" but, ..... um";
*s='x'; //program crashes here...
*p="abc";
*s=*p; // this also cause crashing
........
}
Why does this happen?