Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は自分のコードにこれを持っています
char *ch = &(string[i]); printf(ch);
配列内の特定の要素を印刷したいのですが、変更すると何も印刷されません
char *ch = &(string[20]); printf(ch);
スペース 20 以上のコンテンツが出力されますが、これはなぜですか?どうすれば修正できますか?
事前に感謝
printfcでは文字列はchar*sであるため、onは文字char *にヒットするまですべてを出力します。\0
printf
char *
\0
1文字だけを印刷したい場合は、次のようにします。
printf("%c",ch[0]);