M
Matthew Alton
Why does this code generate a SIGSEGV?
#include <stdio.h>
int
main(void)
{
char *s = "ABC";
s[1] = 'X';
return(0);
}
while this does not:
#include <stdio.h>
int
main(void)
{
char s[] = "ABC";
s[1] = 'X';
return(0);
}
The *s declaration followed by a reference to s[-1] is used in
FreeBSD's strsep(3). It dumps core on Red Hat Linux 7.x and NetBSD
1.6.1.
#include <stdio.h>
int
main(void)
{
char *s = "ABC";
s[1] = 'X';
return(0);
}
while this does not:
#include <stdio.h>
int
main(void)
{
char s[] = "ABC";
s[1] = 'X';
return(0);
}
The *s declaration followed by a reference to s[-1] is used in
FreeBSD's strsep(3). It dumps core on Red Hat Linux 7.x and NetBSD
1.6.1.