April 23, 2010

Segmentation fault

Hi,

I am learning C. I got segmentation fault when I ran the below program.

[root@localhost ~]# more segmentationfault.c
#include
#include
int main()
{
char *mystr="Hi";
strcpy(mystr,"new value") ;
puts(mystr);
return 0;
}

[root@localhost ~]# ./a.out
Segmentation fault
[root@localhost ~]#

Could you please tell me the ways to debug the segmentation fault errors.

Click Here!