初級 › 'x' undeclared エラー(未宣言の変数)の原因と直し方 › パターン4
'x' undeclared エラー(未宣言の変数)の原因と直し方
宣言していない変数を使ったときに出るエラーです。
1 #include <stdio.h> 2 3 int main(void) { 4 _________ = 100; ^ 5 printf("%d\n", score); 6 return 0; 7 }
main.c:4:5: error: 'score' undeclared (first use in this function)
空欄を埋めてコンパイル・実行を通す
scoreという名前も、型を付けて宣言していなければ未知の識別子として扱われます。
次の問題