• <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
            是因?yàn)閟trtok中用static指針記住了上次處理后的位置

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

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

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

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

            9久久9久久精品| 亚洲中文久久精品无码| 亚洲香蕉网久久综合影视| 久久精品国产精品亚洲精品| 一本一道久久a久久精品综合 | 亚洲国产精品久久久久婷婷软件 | 国产成人无码精品久久久性色| 久久强奷乱码老熟女网站| 久久精品国产精品亚洲精品| 久久影视综合亚洲| 久久精品无码一区二区三区免费 | 无码任你躁久久久久久老妇App| 国内精品人妻无码久久久影院导航| 久久天天躁夜夜躁狠狠| 国产精品成人久久久久久久 | 国产69精品久久久久APP下载| 精品无码久久久久国产动漫3d| 精品久久久久中文字| 国产一级做a爰片久久毛片| 无码AV中文字幕久久专区| 狠狠色丁香久久婷婷综合_中| 久久久免费观成人影院| 99久久精品免费看国产| 2022年国产精品久久久久| 精品久久人妻av中文字幕| 久久中文字幕人妻丝袜| 少妇久久久久久被弄到高潮| 99久久婷婷国产综合精品草原| 国产高潮国产高潮久久久91 | 精品综合久久久久久97超人| 久久青青草原亚洲av无码app| 久久精品国产亚洲AV无码麻豆| 久久婷婷国产综合精品| 国产成人久久久精品二区三区| 久久精品国产精品亚洲人人| 一级a性色生活片久久无 | 国产精品久久久久久福利69堂| 国产午夜精品久久久久九九电影| 久久九九免费高清视频| 狠狠色丁香久久婷婷综合五月 | 色婷婷综合久久久久中文一区二区|