初級 › error: expected '}' at end of input の原因と直し方 › パターン3
error: expected '}' at end of input の原因と直し方
波括弧{}の対応が崩れ、閉じ忘れがあるときに出るエラーです。
1 #include <iostream> 2 int main() { 3 while (false) { 4 std::cout << "no" << std::endl; 5 _ ^ 6 return 0; 7 }
main.cpp:7:2: error: expected '}' at end of input
空欄を埋めてコンパイル・実行を通す
g++は「to match this '{'」でどの開き括弧に対応する}が足りないかを教えてくれます。今回はwhileの開き括弧が対応不足です。
次の問題