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

            亚洲精品久久久www| 色欲综合久久中文字幕网| 国产免费久久久久久无码| 亚洲国产成人久久一区WWW| 一本久道久久综合狠狠躁AV| 亚洲精品乱码久久久久久久久久久久 | 久久se精品一区精品二区| 国产精品无码久久四虎| 色综合久久无码中文字幕| 亚洲成色999久久网站| 亚洲国产精品18久久久久久| 国产福利电影一区二区三区久久久久成人精品综合 | 久久男人AV资源网站| 久久精品国产久精国产思思| 青青青青久久精品国产h久久精品五福影院1421 | 波多野结衣久久精品| 国产福利电影一区二区三区,免费久久久久久久精 | 亚洲AV无码1区2区久久 | 嫩草伊人久久精品少妇AV| 中文字幕精品久久久久人妻| Xx性欧美肥妇精品久久久久久| 亚洲AV无一区二区三区久久 | 久久九九青青国产精品| 久久棈精品久久久久久噜噜| 99久久香蕉国产线看观香 | 久久精品a亚洲国产v高清不卡| 国产精品久久久久久久久久影院 | 国产91色综合久久免费| 久久丫精品国产亚洲av不卡| 精品熟女少妇AV免费久久 | 精品无码久久久久久午夜| 99久久无色码中文字幕人妻| 久久久久久伊人高潮影院 | 精品久久综合1区2区3区激情| 久久精品国产一区二区三区日韩| 精品无码久久久久国产| 久久A级毛片免费观看| 久久精品国产亚洲欧美| 国产一久久香蕉国产线看观看| 欧美亚洲国产精品久久蜜芽| 91精品免费久久久久久久久|