初級 › error: ISO C++ forbids comparison between pointer and integer の原因と直し方 › パターン3
error: ISO C++ forbids comparison between pointer and integer の原因と直し方
int型の変数をダブルクォートの文字列リテラル(例: "20")と== で比較しようとしたときに出るエラーです。
1 #include <iostream> 2 int main() { 3 int level = 1; 4 if (level == ___) { ^ 5 std::cout << "beginner" << std::endl; 6 } 7 return 0; 8 }
main.cpp:4:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
空欄を埋めてコンパイル・実行を通す
Pythonなどでは単にfalseになる比較でも、C++は型として比較できないためコンパイルの段階で止まります。
次の問題