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

            Error

            #Error

            關(guān)于strtok函數(shù)

            #include <string.h>
            #include <stdio.h>

            int main(void)
            {
               char input[16] = "abc,dhh,eee";
               char *p;

               /* strtok places a NULL terminator
               in front of the token, if found */
               p = strtok(input, ",");
               if (p)   printf("%s\n", p);

               /* A second call to strtok using a NULL
               as the first parameter returns a pointer
               to the character following the token  */
               p = strtok(NULL, ",");
               if (p)   printf("%s\n", p);

               p = strtok(NULL, ",");
               if (p)   printf("%s\n", p);
               return 0;
            }

            MSDN上的原話:
            On the first call to strtok, the function skips leading delimiters and returns a pointer to the first token in strToken, terminating the token with a null character. More tokens can be broken out of the remainder of strToken by a series of calls to strtok. Each call to strtok modifies strToken by inserting a null character after the token returned by that call. To read the next token from strToken, call strtok with a NULL value for the strToken argument. The NULL strToken argument causes strtok to search for the next token in the modified strToken. The strDelimit argument can take any value from one call to the next so that the set of delimiters may vary.

            第二次參數(shù)竟然可以NULL
            是因為strtok中用static指針記住了上次處理后的位置

            我想是因為這個函數(shù)內(nèi)部實現(xiàn)時,用到了靜態(tài)變量,而要不要修改這個變量,就是要根據(jù)第一個參數(shù)來確定!

            當(dāng)為NULL時,就不再修改Static變量的值了!

            這個靜態(tài)變量的作用,就是記錄原始字符串的長度的!

            posted on 2009-10-07 19:14 Error 閱讀(531) 評論(0)  編輯 收藏 引用 所屬分類: C

            日本久久中文字幕| 久久毛片免费看一区二区三区| 久久精品国产99久久久古代| 久久综合久久美利坚合众国| 久久人人爽人人爽人人AV| 久久久久久久99精品免费观看| 久久99精品久久久久久不卡| 国内精品久久久久久久久电影网| 人妻无码αv中文字幕久久| 91精品国产91热久久久久福利| 日本高清无卡码一区二区久久| 久久无码AV中文出轨人妻| 一本色道久久综合| 欧美亚洲国产精品久久| 亚洲国产精品人久久| 国产欧美久久久精品影院| 青草久久久国产线免观| 久久er国产精品免费观看8| 久久久久久久综合日本亚洲| 久久99国产乱子伦精品免费| 韩国三级大全久久网站| 久久99精品国产| 久久久久99精品成人片三人毛片 | 久久免费99精品国产自在现线| 久久国产成人午夜aⅴ影院| 中文字幕久久久久人妻| 久久亚洲国产精品123区| 久久精品国产一区| jizzjizz国产精品久久| 日韩人妻无码精品久久免费一| 狠狠狠色丁香婷婷综合久久俺| 精品国产乱码久久久久久人妻| 美女久久久久久| 很黄很污的网站久久mimi色 | 久久九九兔免费精品6| 久久综合日本熟妇| 人妻精品久久久久中文字幕 | 精品国产乱码久久久久久人妻| 亚洲精品tv久久久久| 欧美亚洲日本久久精品| 日韩欧美亚洲综合久久影院Ds|