• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            liyuxia713

            蹣跚前行者

            常用鏈接

            統(tǒng)計(jì)

            Algorithms

            C++

            最新評論

            sscanf

            int sscanf(const char* str, const char* format, ...)
            functions: Reads data from str and stores them according to the parameter format into the locations given by the additional arguments. Locations pointed by each additional argument are filled with their corresponding type of value specified in the format string.

            In the format:
            Whitespace character: the function will read and ignore any whitespace characters which are encounterd before the next non-whitespace character.
            Non-whitespace character: except percentage signs(%): any character that is not either a whitespace character or part of a format specifier causes the function to read the next character from str, compare it to this non-whitespace character and if it matches, it is discarded and the function continues with the next character of format and str. If the character does not match, the function fails and returns.
            Return Value:
            On success. the function returns the number of items successfully read.
            On failure: In the case of an input failure before any data could be successfully read, EOF is returnded.
               //默認(rèn)以空格分隔str為不同字符串,返回正確輸入的變量個(gè)數(shù) 
               char buf1[512= {0};
               cout  
            << sscanf("abc def gh","%s",buf1) <<endl;   //1
               cout << buf1 << endl; //abc 
               
               
            //可以使多個(gè)一起存入 
               char buf2[512= {0};
               
            char buf3[512= {0};
               cout 
            << sscanf("abc 2def gh","%s%s",buf2,buf3) <<endl;  //2
               cout << buf2 << endl; //abc 
               cout << buf3 << endl;//2def
               
               
            //空格或format格式以外的字符如果匹配則與前一個(gè)字符串一起輸入,否則停止,退出 
               char buf4[512= {0};
               
            char buf5[512= {0};
               cout 
            << sscanf("abc 2def gh","%s,%s",buf4,buf5) <<endl; //1   
               cout << buf4 << endl; //abc
               cout << buf5 << endl; //nothing

               
            char buf6[512= {0};
               
            char buf7[512= {0};
               
            //注意兩個(gè)%s之間的空格不可少  
               sscanf("abc 2def gh","%s 2%s",buf6,buf7);   
               cout 
            << buf6 << endl; //abc
               cout << buf7 << endl; //def   
               
               
            //當(dāng)然不只是字符串形式的,其他也都可以 
               char buf8[512= {0};
               
            int a;
               cout 
            << sscanf("abc 2def gh","%*s %d",&a) <<endl;//1
               cout << a << endl;//2
               
               
            //Failure 
               int b;
               cout 
            << sscanf("abc","%d",&b) <<endl; //0

            posted on 2010-04-25 20:13 幸運(yùn)草 閱讀(629) 評論(0)  編輯 收藏 引用 所屬分類: C++

            久久久亚洲欧洲日产国码是AV| 色综合久久久久久久久五月| 精品久久久久久亚洲| 久久精品人人做人人爽电影| 青青青国产精品国产精品久久久久 | 精品久久久久久无码中文野结衣| 狠狠久久综合伊人不卡| 午夜视频久久久久一区| www性久久久com| 国产精品乱码久久久久久软件| 久久综合狠狠综合久久| 亚洲精品国产综合久久一线| 色欲久久久天天天综合网精品| 国产69精品久久久久9999| 欧美牲交A欧牲交aⅴ久久| 久久精品国产精品亚洲| 国产精品久久波多野结衣| 亚洲人AV永久一区二区三区久久 | 四虎国产精品免费久久久| 久久人人爽人人爽人人片AV麻烦| 久久精品国产一区| 色欲久久久天天天综合网精品| 亚洲七七久久精品中文国产| 97精品伊人久久久大香线蕉| 久久青青草原精品国产| 久久这里的只有是精品23| 久久免费国产精品| 久久久91人妻无码精品蜜桃HD| 99久久综合狠狠综合久久止| 久久伊人五月丁香狠狠色| 香蕉久久夜色精品国产2020| 久久精品无码一区二区三区日韩| 久久伊人精品青青草原高清| 精品久久久久久久无码| 色欲av伊人久久大香线蕉影院 | 久久99精品久久久久久噜噜| 国产精品久久久久久久久鸭| 久久久久亚洲AV无码麻豆| 日日噜噜夜夜狠狠久久丁香五月| 亚洲愉拍99热成人精品热久久 | 国内高清久久久久久|