以下是我模仿其他的程序写的,可运行时总是显示有为
--------------------Configuration: Cexample3_163 - Win32 Debug--------------------
Compiling...
Cexample3_163.cpp
E:\something\200542625347542\C++应用编程200例\cp3\Cexample3_163\Cexample3_163.cpp(27) : error C2660: 'strcmp' : function does not take 3 parameters
E:\something\200542625347542\C++应用编程200例\cp3\Cexample3_163\Cexample3_163.cpp(46) : error C2660: 'strcmp_put' : function does not take 3 parameters
Error executing cl.exe.
Cexample3_163.obj - 2 error(s), 0 warning(s)
我不知道哪里错的,请各位高手给指点一下,谢谢你啊
程序如下:
#include<iostream.h>
#include<string.h>
void str_input(char* p1,char* p2)
{
cout<<"string1:";
cin>>p1;
cout<<"string2:";
cin>>p2;
}
void strcmp_put(char* p1,char* p2)
{
cout<<"strcmp():"<<endl;
int result=strcmp(p1,p2);
if(result>0)
cout<<p1<<"greater than"<<p2<<endl;
if(result<0)
cout<<p1<<"less than"<<p2<<endl;
if(result==0)
cout<<p1<<"identical"<<p2<<endl;
}
void strncmp_put(char* p1,char* p2,size_t count)
{
cout<<"strncmp():"<<endl;
int result=strcmp(p1,p2,count);
if(result>0)
cout<<p1<<"greater than"<<p2<<endl;
if(result<0)
cout<<p1<<"less than"<<p2<<endl;
if(result==0)
cout<<p1<<"identical to"<<p2<<endl;
}
void main(void)
{
char str1[80],str2[80],p;
int i;
for(i=1;i<=3;i++)
{
str_input(str1,str2);
strcmp_put(str1,str2);
strcmp_put(str1,str2);
strcmp_put(str1,str2,3);
cout<<"-------------------"<<endl;
}
}