检查字符
Checking characters
如何检查字符数组?例如,我正在编写一个程序,要求我输入密码,比如ZEZO,然后它检查密码是否正确,然后打印"hello ZEZO"。我目前使用turbo c++为学校的东西。我有一个示例程序:
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
char * zezo;
zezo = "Zezo";
cout<<"Hello "<<zezo;
}
我只需要知道如何得到单词检查
使用std::string
代替char*
,然后使用operator ==
或compare
检查字符串
iostream.h
和conio.h
?void main
吗?寻找新的学习材料,越快越好,因为不管你现在学的是什么,都是非常糟糕的。
#include <iostream>
#include <string>
int main() {
std::string s;
std::cin >> s;
if (s == "Zezo")
// Cool
else
// Not cool
}
strcmp
bool matches = strcmp(zezo, "ZEZO") == 0
查找strcmp,最好查找std::string和相关函数
相关文章:
- 如何检查一个c++字符串中有多少相同的字符/数字
- 检查向量是否具有所有可能的字符组合
- 如何检查 UnicodeString 的字符?
- 在做一段时间内检查字符的无限循环
- 我遇到了这个代码片段,不明白. 它递归检查 C++ 字符串中是否存在大写字符
- 如何检查用户是否输入了元音字符?
- 如何检查一个字符是否与字符数组中的另一个字符匹配?
- 有没有办法搜索向量的元素,<String>然后检查它是否包含特定的字符,如果它确实打印了它
- 尝试使用 indexOf 创建一个 if 语句来检查字符串是否包含字符.有一点麻烦
- 检查更大的字符
- 如何检查字符串是否包含所有这些:数字、字母和特殊字符
- 如果是数字或字符,请检查输入
- 检查数组中的字符对
- 如何检查字符串中的最后一个字符是否是某个字符并将其从字符串中删除?(C++)
- 如何检查二维字符数组是否有空字
- 如何检查输入是否为字符并显示它是"invalid input",否则它将按原样运行
- C++字符检查给出了惊人的值
- c++唯一字符检查
- c++字符检查
- C++简单的字符检查