Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.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

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++_String_Compare - Fatal编程技术网

C++ 检查字符

C++ 检查字符,c++,string,compare,C++,String,Compare,如何检查字符数组?例如,我正在制作一个程序,要求我输入密码,比如说ZEZO,然后它检查密码是否正确,然后打印“hello ZEZO”。我现在使用Turbo C++来做学校的事情。我有一个示例程序: #include <iostream.h> #include <conio.h> void main() { clrscr(); char * zezo; zezo = "Zezo"; cout<<"Hello "<<

如何检查字符数组?例如,我正在制作一个程序,要求我输入密码,比如说ZEZO,然后它检查密码是否正确,然后打印“hello ZEZO”。我现在使用Turbo C++来做学校的事情。我有一个示例程序:

#include <iostream.h>
#include <conio.h>

void main()
{
    clrscr();
    char * zezo;
    zezo = "Zezo";

    cout<<"Hello "<<zezo;
}
#包括
#包括
void main()
{
clrsc();
char*zezo;
zezo=“zezo”;
cout


使用a而不是
char*
,然后使用
操作符==
比较
来检查字符串。

搜索strcmp,更好地搜索std::string和相关函数

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 
}
#包括
#包括
int main(){
std::字符串s;
标准:cin>>s;
如果(s==“Zezo”)
//酷
其他的
//不酷
}

< DotNetZeZo >他说,标题是错误的,主要签名无效。你应该得到一本更好的书。(如果教授给你这个代码,并说它是C++,愿上帝宽恕你的灵魂。)您可以免费获得Clang 3.2、MinGW 4.7.2或Visual Studio 2012 Express。它们都是本世纪的编译器,而且性能卓越。
#include <iostream>
#include <string>

int main() {
    std::string s;
    std::cin >> s;
    if (s == "Zezo")
        // Cool
    else
        // Not cool 
}