Hello guys,
Here is the test code which is segfaulted:
cat ptr.c
#include <stdio.h>
int main()
{
char *ch = "abc";
ch++;
*ch = "A";
printf("%c", *ch);
return 0;
}
The question is: why I cannot write the "A" character instead of "b"?
Here is the test code which is segfaulted:
cat ptr.c
#include <stdio.h>
int main()
{
char *ch = "abc";
ch++;
*ch = "A";
printf("%c", *ch);
return 0;
}
The question is: why I cannot write the "A" character instead of "b"?
Aucun commentaire:
Enregistrer un commentaire