Neden programı,C Char işaretçiler ++
char *s, *p, c;
s = "abc";
printf(" Element 1 pointed to by S is '%c'\n", *s);
printf(" Element 2 pointed to by S is '%c'\n", *s+1);
printf(" Element 3 pointed to by S is '%c'\n", *s+2);
printf(" Element 4 pointed to by S is '%c'\n", *s+3);
printf(" Element 5 pointed to by S is '%c'\n", s[3]);
printf(" Element 4 pointed to by S is '%c'\n", *s+4);
aşağıdaki sonuçları veriyor artırım yapılması?
Element 1 pointed to by S is 'a'
Element 2 pointed to by S is 'b'
Element 3 pointed to by S is 'c'
Element 4 pointed to by S is 'd'
Element 5 pointed to by S is ' '
Element 4 pointed to by S is 'e'
Derleyici sıralamaya nasıl devam etti? Ve neden s[3]
boş bir değer döndürüyor?
Öncelik. İstediğiniz * (s + 1) 'vb. Ama' * (s + 4) 'undefined davranışı olacaktır. –
's [3]', '\ 0' karakterini sonlandıran bir dize olan 4'üncü karakteri (0'dan dizinlenmiş) döndürür. –
'ın [3]' '\ 0', bu yüzden ben bu Öğe 5 çıktının şüpheci hiçbiri –