在工作中碰见了strncmp函数,在由C转Java时由于不了解它的返回值范围,导致出错,出单员不能录单,问题比较严重。下面是工作中碰见的一段代码:
if (strcmp(sCtctCde,"014012")==0){
    if ((strcmp(sBsnsTyp,"19001")==0) || (strcmp(sBsnsTyp,"19007")==0)){
     sprintf(stmp,"该部门属性为专属4S店,业务来源只能选择机构代理!");
      return(SetUserError(lpInBuffer,2,stmp));
    }else if (strncmp(sProdNo,"03",2)){    //如果相等返回为 0 ,而不是true。
       sprintf(stmp,"该部门属性为专属4S店,只能出车险业务!");
       return(SetUserError(lpInBuffer,2,stmp));
    }
   }

 
strncmp() 函数 用法

函数的作用是:比较字符串的前n个字符(大小写敏感)。

这个函数将返回下列值:
0 – 如果字符串相等 
<0 – 如果string1小于string2
>0 – 如果string1大于string2

语法:strncmp(string1,string2,length)

 

相关文章:

  • 2022-01-12
  • 2021-07-29
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
  • 2022-01-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
相关资源
相似解决方案