mercredi 5 mars 2014

Change the second element of char array topic




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"?





Aucun commentaire:

Enregistrer un commentaire