Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 验证两个字符串在C+中是否相等+;_C++_String_Function_Boolean - Fatal编程技术网

C++ 验证两个字符串在C+中是否相等+;

C++ 验证两个字符串在C+中是否相等+;,c++,string,function,boolean,C++,String,Function,Boolean,我正在做一个赋值,要求我使用一个函数来检查两个字符串是否相等。在调用函数的第20行,我一直遇到一个解析错误,我不知道出了什么问题。请看一看,如果您看到问题的原因,请告诉我。谢谢 #include <iostream> #include <string> using namespace std; bool checker(string firstWordParameter, string secondWordParameter); int main() { s

我正在做一个赋值,要求我使用一个函数来检查两个字符串是否相等。在调用函数的第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;
    }
}
#包括
#包括
使用名称空间std;
布尔检查器(字符串firstWordParameter、字符串secondWordParameter);
int main()
{
字符串第一个字,第二个字;
布尔匹配;
不能试着改变

match = bool checker(firstWord, secondWord);
进入

第20行是

 match = bool checker(firstWord, secondWord);
换成

match = checker(firstWord, secondWord);

此外,当您在编译器中看到错误时,双击它,它将显示有错误的行。

如果您能告诉我们第20行在哪里,那就太好了……为什么不看几分钟第20行?或者至少只发布周围的(+-1行)代码?:pThanks a tong,这就是我所需要的。现在开始工作:)谢谢。是的,我知道这是第20行,我只是不明白为什么它不喜欢我的函数调用。我感谢你的帮助,这个网站的用户可能是恶意的。谢谢,如果你接受我的答案(勾选它),我将不胜感激
match = checker(firstWord, secondWord);