char *s;
char buf [] = "This is a test";
s = strchr (buf, 't');
if (s != NULL)
printf ("found a 't' at %s\n", s);
printf("%c\n",*s);
printf("%c\n",*s++);
printf("%c\n",*s++);
printf("%c\n",*s++);
printf("%c\n",*s++);
このコード出力:私の見解ではなぜ* sと* s ++が同じ値を持つのか?
found a 't' at test
t
t
e
s
t
Program ended with exit code: 0
は、* sがt
であるべきで、* S ++ e
でなければなりません。しかし、なぜ彼らはこのコードで同じ価値を持っていますか?式*s++
で
「あなたの意見」は何かに基づいていますか? –
ポストインクリメント手段は、インクリメントしてインクリメントします。 Try *(++ s) – sircodesalot
sは文字列sの先頭アドレスを意味するので、* sはアドレスに格納されている値でなければなりません。 s ++は文字列sの先頭アドレスから次の位置になければなりません。 –