我正在尝试将一个字符串与另一个字符串进行比较。这是我的代码
#include <iostream>
#include <string>
using namespace std;
int main()
{
string verse = "Jn 3:30 Es nesesario que El cresca, pero que yo mengue.";
string entverse;
int opc;
cin >> entverse;
if (entverse == verse)
{
cout << "amen!";
}
else
{
cout << "oops!";
}
system("pause");
}
当我写对时,它应该打印“阿门”,但它没有。为什么?
您将需要使用 getline 而不是 cin。查看有关 getline 的文档。http://www.cplusplus.com/reference/string/string/getline/
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句