🔤 文字列
char s[10]; s = "hello"; で gcc: error: assignment to expression with array type、clang: error: array type 'char[10]' is not assignable。
配列名は「先頭を指す入れ物そのもの」なので、丸ごと代入はできません。= で文字列を書けるのは、宣言と同時の初期化のときだけです。
あとから入れるなら strcpy(s, "hello");、安全に書くなら snprintf(s, sizeof s, "%s", "hello");。宣言時なら char s[10] = "hello"; と書けます。同じ理由で、文字列の比較も == ではなく strcmp を使います。
もっと先へ:ポインタ・メモリ・ファイル入出力・セキュアコーディングを含む全26トラックと、段位検定・模試のフルセットは完全版に収録しています。