验证C 中的两个字符串是否相等
Verify if two strings are equal in C++
我正在做一个分配,要求我使用功能检查两个字符串是否相等。我在第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;
}
}
尝试更改
match = bool checker(firstWord, secondWord);
进入
match = checker(firstWord, secondWord);
第20行是
match = bool checker(firstWord, secondWord);
将其更改为
match = checker(firstWord, secondWord);
同样,当您看到编译器中的错误时,请双击它,然后向您显示错误。
相关文章:
- 两个字符串在 c++ 中不相等
- 在C++的两个字符串中连接以逗号分隔的唯一值
- 将字符串拆分为标记,并将标记拆分为两个单独的数组
- 如何从文件中读取两个字符串和数字数组,并将它们存储在对象向量中
- 比较两个字符串后卡在无限循环中
- 我已经建立了递归关系,它找到了两个字符串之间最长的连续公共字符串,我怎么能跳过其中一个字符串中的一个字符
- 使用XOR查找O(n)-解决方案中的两个字符串是否为变位符
- 如何将字符串和整数读取到两个单独的动态数组中的程序编写?
- 如何将两个字符串加在一起,就好像它们是变量一样?
- 我需要帮助在一个类中输入两个字符串并获取其输出
- 这两个C++语句连接字符串有什么区别?
- 两个字符串之间的数学运算
- 使用 SET(C++) 检查两个给定字符串是否是字谜时出现运行时错误
- 有没有办法我可以在 C++ 中使用 if 语句来说明如果一个字符串不是两个名称的 eqal,它会给出一个输出,ATM i
- 如何在 main 函数中输出两个新字符串C++?
- sscanf() 有两个字符串参数
- 我的字符串数组一次打印出前两个字符串
- 两个 c++ 字符串上的异或
- 函数返回两个字符串的第一个常用字符
- 目标是找到两个 c 字符串之间的公共前缀(必须使用特定的函数标头)