初級 › error: 'x' undeclared (first use in this function) の原因と直し方 › パターン1
error: 'x' undeclared (first use in this function) の原因と直し方
宣言していない変数を使ったときに出るエラーです。
1 #include <stdio.h> 2 3 int main(void) { 4 _____ = 5; ^ 5 printf("%d\n", x); 6 return 0; 7 }
main.c:4:5: error: 'x' undeclared (first use in this function)
空欄を埋めてコンパイル・実行を通す
変数は使う前に型を付けて宣言する必要があります。代入する行だけでは宣言になりません。
次の問題