斷點

          每天進步一點點!
          posts - 174, comments - 56, trackbacks - 0, articles - 21

          C++語法小記

          Posted on 2010-01-12 23:37 斷點 閱讀(246) 評論(0)  編輯  收藏 所屬分類: C++

          1、strcpy(str2,""); /*將str2清空*/

          2、num1=atof(str2); /*將第二個操作數轉換為浮點數*/

          3、int strcmp(char *s1,char * s2);      

          用法:#include <string.h>
          功能:比較字符串s1和s2。
          說明:
                  當s1<s2時,返回值<0
                  當s1=s2時,返回值=0
                  當s1>s2時,返回值>0

          posted @ 2009-06-03 11:35 斷點 閱讀(31) | 評論 (0)


          4、strncmp(char *s1,char * s2,int n);
          用法:#include <string.h>
          功能:比較字符串s1和s2的前n個字符。
          說明:
                  當s1<s2時,返回值<0
                  當s1=s2時,返回值=0
                  當s1>s2時,返回值>0
          實戰:
          在工作中碰見了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));
              }
             }
          可參考:http://www.ggv.com.cn/forum/clib/string/strncmp.html

          posted @ 2009-09-11 19:28 斷點 閱讀(153) | 評論 (0)


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 荔浦县| 灵石县| 广宁县| 巴马| 泰顺县| 白山市| 佛山市| 黄山市| 十堰市| 陇南市| 黑龙江省| 噶尔县| 阳江市| 台南县| 西林县| 恩平市| 汉源县| 惠州市| 舟山市| 长岭县| 汽车| 沿河| 资中县| 万年县| 鸡东县| 昭苏县| 灵宝市| 治多县| 夏邑县| 蒙自县| 阜平县| 南阳市| 宁安市| 无棣县| 梓潼县| 博乐市| 广河县| 西青区| 海淀区| 外汇| 高雄市|