【发布时间】:2014-02-26 06:08:36
【问题描述】:
我正在做一个作业,要求我使用一个函数来检查两个字符串是否相等。我在调用函数的第 20 行不断收到解析错误,我不知道出了什么问题。如果您发现可能导致问题的原因,请查看并告诉我。谢谢!
#include <iostream>
#include <string>
using namespace std;
bool checker(string firstWordParameter, string secondWordParameter);
int main()
{
string firstWord, secondWord;
bool match;
cout << "Hello user.\n"
<< "This program will determine whether two words are the same.\n"
<< "Please enter your first word you would like to check: ";
getline(cin, firstWord);
cout << "Great, now enter the second word: ";
getline(cin, secondWord);
match = bool checker(firstWord, secondWord);
if(match == true){
cout << "Match.";
}else{
cout << "Totally not a match.";
}
return 0;
}
bool checker(string firstWordParameter, string secondWordParameter)
{
if(firstWordParameter == secondWordParameter){
return true;
}else{
return false;
}
}
【问题讨论】:
-
如果您能告诉我们第 20 行在哪里就太好了...
-
你为什么不看看第 20 行几分钟?或者至少只是发布周围的(+- 1 行)代码? :p
标签: c++ string function boolean