#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
string A1;
cin>>A1;
if(A1==0)
{
cout<<"Success!";
}
else
{
cout<<"Failure!";
}
system("PAUSE");
return 0;
}
C++初學者。我試圖使用==運算符來比較鍵入的字符串值爲0。以上是我的代碼示例。我如何以最簡單的方式解決這個問題?謝謝。C++使用==運算符將字符串比較爲0?
可能你的意思是「0」。 –
不確定你的意圖......與「0」比較或比較「0」 – jsantander
問題是什麼?你想檢查是否輸入了字符串「0」?或檢查NULL? – Theolodis