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

            最新評(píng)論

            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)草 閱讀(622) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C++

            伊人伊成久久人综合网777| 91精品国产91久久综合| 国产精品九九久久免费视频| 国产成人综合久久精品红| 狠狠色综合网站久久久久久久| 国产成人精品免费久久久久| 亚洲精品美女久久久久99| 亚洲欧美日韩精品久久亚洲区| 久久精品成人免费国产片小草| 久久久久亚洲AV成人网人人网站| 久久国产美女免费观看精品| 久久亚洲国产欧洲精品一| 韩国无遮挡三级久久| 女人香蕉久久**毛片精品| 97久久精品午夜一区二区| 国产精品女同久久久久电影院| 久久精品九九亚洲精品| 久久精品亚洲中文字幕无码麻豆| 久久香综合精品久久伊人| 久久久久久亚洲精品成人| 国产精品久久久久久吹潮| 国产麻豆精品久久一二三| 69SEX久久精品国产麻豆| 精品久久777| 99久久精品免费看国产一区二区三区 | 中文精品久久久久人妻不卡| 久久久国产视频| 精产国品久久一二三产区区别| 亚洲欧美日韩中文久久 | 69国产成人综合久久精品| a级成人毛片久久| 国产成人精品久久亚洲高清不卡| 久久精品国产黑森林| 伊人久久大香线蕉成人| 亚洲AV无码久久精品色欲| .精品久久久麻豆国产精品| 日本免费一区二区久久人人澡| 久久精品国产精品亚洲下载| 久久久无码精品亚洲日韩蜜臀浪潮| 久久综合噜噜激激的五月天| 情人伊人久久综合亚洲|