• <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 幸運草 閱讀(631) 評論(0)  編輯 收藏 引用 所屬分類: C++

            精品熟女少妇AV免费久久| 国产精品99久久久精品无码| 久久精品国产亚洲欧美| 狠狠色伊人久久精品综合网| 亚洲&#228;v永久无码精品天堂久久 | 久久人妻AV中文字幕| 嫩草伊人久久精品少妇AV| 国产综合精品久久亚洲| 久久精品无码一区二区无码| 午夜精品久久影院蜜桃| 国产欧美久久久精品| 久久久久久久女国产乱让韩| 精品无码久久久久久国产| 久久久久人妻一区精品色| 中文字幕无码av激情不卡久久| 久久精品国产69国产精品亚洲| 亚洲香蕉网久久综合影视| 青青热久久国产久精品 | 免费一级欧美大片久久网| 热re99久久精品国产99热| 久久久一本精品99久久精品66| 少妇熟女久久综合网色欲| 国产精品99久久久久久猫咪 | 99久久国产亚洲综合精品| 国产三级精品久久| 日本久久久精品中文字幕| www性久久久com| 精品国产乱码久久久久久1区2区| 久久亚洲AV无码精品色午夜 | 久久这里有精品| 久久久久女教师免费一区| 久久se精品一区二区影院| 99久久精品免费看国产免费| 色综合久久中文综合网| 国产91久久综合| 久久精品国产99国产精品| 久久精品中文字幕一区| 亚洲欧洲久久久精品| 中文字幕久久波多野结衣av| 久久亚洲精品无码AV红樱桃| 精品国产乱码久久久久久1区2区 |