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