下列程序输出的是( )
string ch="hello";
if(ch[5]==NULL)
{
cout<<"right"<<endl;
}
else if (ch[5]=='\0')
{
cout<<"wrong"<<endl;
}
else
{
cout<<"hello"<<endl;
}
- A. right
- B. wrong
- C. hello
- D. 不能正确执行
正确答案:A
string ch="hello";
if(ch[5]==NULL)
{
cout<<"right"<<endl;
}
else if (ch[5]=='\0')
{
cout<<"wrong"<<endl;
}
else
{
cout<<"hello"<<endl;
}
正确答案:A
想系统刷完 GESP C++ 1~8 级真题,并查看每道题的逐题精讲?
进入 GESPPASS 开始练习