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)

解决方案 »

  1.   

    字符比较就不需要strcmp了,直接用 if (pStr[iIndex] != pMac[iEnd])
      

  2.   

    同上,strcmp是比较字符串的,字符直接用关系运算符比较。
      

  3.   

    strcmp  
      原型:extern int strcmp(char *s1,char * s2);      
      用法:#include <string.h>strcmp的参数是指向字符串头地址的指针(4个字节)
       iCmp=strcmp(pStr[iIndex], pMac[iIndex]); 这里的参数是char(一个字节)错在参数类型不匹配
     
      

  4.   

    iCmp=strcmp(pStr[iIndex], pMac[iIndex]); 
    那这句要怎么改呢?
      

  5.   

    如果你只想改这一行的话:
    iCmp = pStr[iIndex] - pMac[iIndex];