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