初級 › error: expected declaration or statement at end of input の原因と直し方 › パターン1
error: expected declaration or statement at end of input の原因と直し方
波括弧{}の対応が崩れ、閉じ忘れがあるときに出るエラーです。
1 #include <stdio.h> 2 3 int main(void) { 4 printf("hi\n"); 5 return 0; 6 _ ^
main.c:5:5: error: expected declaration or statement at end of input
空欄を埋めてコンパイル・実行を通す
main関数を開いた{を閉じ忘れています。ファイルの終わりまで読んでもブロックが閉じないため、末尾でエラーになります。
次の問題