文字列の可変配列を反復処理する最良の方法は何ですか?たとえば:Cでの文字列操作の配列
struct Book{
char chapter_names[20][50];
int chapters;
...}
int main(){
struct Book Redwall;
strcpy(*chapter_names, "The Wall");
strcpy(*(++chapter_names), "The Grove");
printf("Chapter 1: %s", chapter_names[0]);
printf("Chapter 2: %s", chapter_names[1]);
return 0;
}
私はこれの出力はになりたい:
Chapter 1: The Wall
Chapter 2: The Grove
このコードは、あなたがアレイ上でそのようなインクリメント演算子を使用することはできません
error: lvalue is required as increment operand
このコードをコンパイルするとどうなりましたか? –
質問に編集しました – David
'chapter_names'は配列です。配列をインクリメントすることはできません。 –