I compiled the following code on gcc :
On running it gave Segmentation fault. On running the debugger, I found that the problem was in :Code:# include <stdio.h> fun(char str[100]) { str[0]='c'; } int main() { fun("wah"); return 0; }
If I first take "wah" in a string variable, and then pass that variable to fun(), then there is no problem. Why is this happening ?Code:str[0]='c';