#include<iostream.h>
#include<string.h>
void main()
{
char s[4];
strcpy(s,"quit 123");
cout<<strcmp(s,"quit")<<endl;
}为什么结果是1,而不是0呢
#include<string.h>
void main()
{
char s[4];
strcpy(s,"quit 123");
cout<<strcmp(s,"quit")<<endl;
}为什么结果是1,而不是0呢
调试欢乐多
1 大于
0 等于
-1 小于
这句已经越界了
s的长度没有'\0'结束符,s串的长度就不确定
所以比较出来的结果不正确