strcmp问题,为什么两个字符明明相等却不能等于0!
来源:百度知道 编辑:UC知道 时间:2024/06/05 13:01:20
while((q=getchar())!='\n')
{
if(q=='0'||q=='1')
{
input[num1++]=q;
}
else
cout<<"输入错误!请输入一串以1和0组成的huffman编码"<<endl;
}
for(j=0;j<num1;j++)
cout<<input[j];
char a[]="111";
cout<<strcmp(a,input)<<endl;
当我输入111时,还是不等于0~~~
其中
char input[10];
{
if(q=='0'||q=='1')
{
input[num1++]=q;
}
else
cout<<"输入错误!请输入一串以1和0组成的huffman编码"<<endl;
}
for(j=0;j<num1;j++)
cout<<input[j];
char a[]="111";
cout<<strcmp(a,input)<<endl;
当我输入111时,还是不等于0~~~
其中
char input[10];
不值相等的把,你input[10]的长度是11,
而a[]的长度是3
你要是让input[10]的长度是111,要在后面加个
\0
比如:input[0]={'1','1','1','\0'};
\0是字符串结尾吗,没有\0只能到input[9]结束。
strcmp的问题???
C程序问题(strcmp 的怪现像)
1. 编写一个strcmp函数实现两个字符串的比较:
C语言编程-用数组方法编写函数strcmp,比较两个字符串的大小。
(c语言数组的!)比较两个字符串的大小。(不可以用strcmp做)
请编写程序输入两个字符串,比较两个字符串的大小,要求松strcmp函数的功能。
我想问一下字符串比较函数int strcmp(char *str1,char *str2)的问题?
测试strCmp函数
关于strcmp函数
c语言问题,高手帮下忙吧~?type mismatch in parameter 's1' in call to 'strcmp'