if eles 问题

来源:互联网 发布:扫地机器人算法 编辑:程序博客网 时间:2024/06/06 07:37
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
const int Size = 15;
char n1[Size];
char n2[Size]="C++owboy";
char n3[] = "lson";
cout << "Howdy! IM" << n2 << "! your name?\n";
cin >> n1;
if (n1 == n3)
cout << "well, " << n1 << "I konw you\n";
else
{
cout << "well, " << n1 << " your name has" << strlen(n1) << " letters and is stored\n";
cout << "in a array of " << sizeof(n1) << "bytes.\n";
cout << "your is " << n1[0] << endl;
n2[3] = 0;
cout << "my name: " << n2 << endl;
}
return 0;

}

奇怪的是我输入lson,却是显示的为else的内容,现在没有看到if那章,但不应该,留着以后看看

0 0
原创粉丝点击