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

            關于strtok函數

            #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.

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

            我想是因為這個函數內部實現時,用到了靜態變量,而要不要修改這個變量,就是要根據第一個參數來確定!

            當為NULL時,就不再修改Static變量的值了!

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

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

            久久er国产精品免费观看8| 久久精品国产99久久丝袜| 久久亚洲国产精品五月天婷| 99久久99久久久精品齐齐| 91精品国产综合久久婷婷| 99精品久久精品一区二区| 99久久人妻无码精品系列蜜桃| 熟妇人妻久久中文字幕| 精品久久8x国产免费观看| 国产精品视频久久久| 久久中文娱乐网| 久久精品视屏| 一本一道久久综合狠狠老| 久久久久人妻一区精品色| 7国产欧美日韩综合天堂中文久久久久| 精品久久久久久国产| 久久国产精品免费一区| 亚洲精品tv久久久久久久久久| 欧美黑人激情性久久| 久久国产精品77777| 91精品国产高清久久久久久91 | 免费精品久久久久久中文字幕| 久久精品无码av| 亚洲午夜久久久久妓女影院| 久久精品国产亚洲av高清漫画| 国产精品久久成人影院| 久久香蕉国产线看观看猫咪?v| 久久人做人爽一区二区三区| 精品蜜臀久久久久99网站| 91秦先生久久久久久久| 久久久亚洲欧洲日产国码是AV | 久久精品国产91久久综合麻豆自制| 国产精品伊人久久伊人电影| 免费精品国产日韩热久久| 91久久精品91久久性色| 久久久亚洲裙底偷窥综合| 99久久精品国产一区二区| 久久久免费精品re6| 最新久久免费视频| 久久99国产一区二区三区| 精品国产VA久久久久久久冰 |