• <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

            蹣跚前行者

            常用鏈接

            統計

            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.
               //默認以空格分隔str為不同字符串,返回正確輸入的變量個數 
               char buf1[512= {0};
               cout  
            << sscanf("abc def gh","%s",buf1) <<endl;   //1
               cout << buf1 << endl; //abc 
               
               
            //可以使多個一起存入 
               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格式以外的字符如果匹配則與前一個字符串一起輸入,否則停止,退出 
               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};
               
            //注意兩個%s之間的空格不可少  
               sscanf("abc 2def gh","%s 2%s",buf6,buf7);   
               cout 
            << buf6 << endl; //abc
               cout << buf7 << endl; //def   
               
               
            //當然不只是字符串形式的,其他也都可以 
               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 幸運草 閱讀(629) 評論(0)  編輯 收藏 引用 所屬分類: C++

            国产∨亚洲V天堂无码久久久 | 久久这里有精品视频| 亚洲精品乱码久久久久久蜜桃图片| 久久99精品国产麻豆不卡| 精品永久久福利一区二区| 久久久老熟女一区二区三区| 久久亚洲精品国产精品| av无码久久久久久不卡网站| 国内精品久久久久| 亚洲国产天堂久久综合网站| 国产亚洲色婷婷久久99精品91| 理论片午午伦夜理片久久 | 久久久久人妻一区二区三区vr| 国产精品99久久久精品无码| 无码乱码观看精品久久| 久久这里都是精品| 亚洲精品乱码久久久久久蜜桃不卡| 久久天天躁狠狠躁夜夜2020一 | 久久久综合九色合综国产| 青青草原综合久久大伊人精品| 久久99久久成人免费播放| 日本高清无卡码一区二区久久| 久久香综合精品久久伊人| 久久精品午夜一区二区福利| 91精品国产91久久久久久青草| 久久97久久97精品免视看秋霞| 国产精品久久久久a影院| 久久久久免费看成人影片| 亚洲精品高清久久| 奇米影视7777久久精品人人爽| 人妻无码αv中文字幕久久琪琪布| 久久精品国产亚洲综合色| 亚洲午夜无码久久久久小说| 国内精品人妻无码久久久影院| 久久精品国产一区二区| 亚洲国产精品无码久久| 久久91这里精品国产2020| 久久精品a亚洲国产v高清不卡| 久久综合久久伊人| 久久91精品国产91久久小草 | 久久水蜜桃亚洲av无码精品麻豆|