int ErFen(char *pStr, char *pMac)
{
int iIndex;
int iStart=0;
int iEnd=sizeof(*pMac)/sizeof(char *)-1;
int iCmp;
int iResult=-1; for(;;)
{
iIndex=(iStart+iEnd)/2; iCmp=strcmp(pStr[iIndex], pMac[iIndex]);
if(iCmp>0)
{
iStart=iIndex;
}
else if(iCmp<0)
{
iEnd=iIndex;
}
else
{
iResult=iIndex;
break;
}
if(iEnd-iStart==1)
{
if(!strcmp(pStr[iIndex],pMac[iEnd]))
iResult=iIndex;
break;
}
}
return iResult;
}
.cpp(351) : error C2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
cpp(367) : error C2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.Cpp1scan.exe - 2 error(s), 0 warning(s)
{
int iIndex;
int iStart=0;
int iEnd=sizeof(*pMac)/sizeof(char *)-1;
int iCmp;
int iResult=-1; for(;;)
{
iIndex=(iStart+iEnd)/2; iCmp=strcmp(pStr[iIndex], pMac[iIndex]);
if(iCmp>0)
{
iStart=iIndex;
}
else if(iCmp<0)
{
iEnd=iIndex;
}
else
{
iResult=iIndex;
break;
}
if(iEnd-iStart==1)
{
if(!strcmp(pStr[iIndex],pMac[iEnd]))
iResult=iIndex;
break;
}
}
return iResult;
}
.cpp(351) : error C2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
cpp(367) : error C2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.Cpp1scan.exe - 2 error(s), 0 warning(s)
原型:extern int strcmp(char *s1,char * s2);
用法:#include <string.h>strcmp的参数是指向字符串头地址的指针(4个字节)
iCmp=strcmp(pStr[iIndex], pMac[iIndex]); 这里的参数是char(一个字节)错在参数类型不匹配
那这句要怎么改呢?
iCmp = pStr[iIndex] - pMac[iIndex];