cº¯Êý: strtok ºÍ strtok_r
º¯ÊýÃû: strtok
¹¦ ÄÜ: ²éÕÒÓÉÔÚµÚ¶þ¸ö´®ÖÐÖ¸¶¨µÄ·Ö½ç·û·Ö¸ô¿ªµÄµ¥´Ê
ÓÃ ·¨: char *strtok(char *str1, char *str2);
³ÌÐòÀý:
#include <string.h>
#include <stdio.h>
int main(void)
{
char input[16] = "abc,d";
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);
return 0;
}
´øÓÐ_rµÄº¯ÊýÖ÷ÒªÀ´×ÔÓÚUNIXÏÂÃæ¡£ËùÓеĴøÓÐ_rºÍ²»´ø_rµÄº¯ÊýµÄÇø±ðµÄÊÇ:´ø_rµÄº¯ÊýÊÇḬ̈߳²È«µÄ£¬rµÄÒâ˼ÊÇreentrant,¿ÉÖØÈëµÄ¡£
ÉÏÊö³ÌÐòÔËÐеĽá¹ûÊÇ
abc
d
1. strtok½éÉÜ
ÖÚËùÖÜÖª£¬strtok¿ÉÒÔ¸ù¾ÝÓû§ËùÌṩµÄ·Ö¸î·
Ïà¹ØÎĵµ£º
½ñÌìÔÚCCÉÏ¿´µ½evangelÔÚÕÐÈË£¬ÉÏÃæдÁËÒ»ÌõÊý¾Ý½âÎö£¬ÎÒÏëÓ¦¸Ã¾ÍÊǶÔXMLµÄ½âÎö°É£¬ÔÝÇÒÕâÑùÀí½âÁË£¬ºÇºÇ¡£ÏÂÎçËÑË÷ÁËÒ»µã¶«Î÷×Ô¼ºÅªÁËÒ»¸öXMLÈ»ºó¶Á¶Á¿´¿´£¬ÏÖÔÚ½ö½öÊǶÁ³öÁËһЩ¶«Î÷£¬Ïȱ£´æ´úÂ룬´ýºóÐø¸üУ¡
Õâ¸öÊÇÎÒ´´½¨µÄxmlÎļþ£¬ÓÃÓÚ²âÊÔÓõģº
<?xml version="1.0" e ......
ÕâÁ½ÌìÓкܶàÅóÓÑÒѾÂòÁËÊéÁË£¬²¢ÇÒ¿ªÊ¼¿´£¬ºÇºÇ£¬ÎÒÐÄÀïÒ²ºÜ¸ßÐË¡£
àÅ£¬ÒªËµ½ºþÉϲØÁúÎÔ»¢ÄØ£¬Õâ²»£¬Õâ²Å¼¸Ììʱ¼ä£¬ÒѾÓÐÅóÓÑÖ¸³öÎÒÊéÖеÄÒ»´¦Ã÷ÏÔ´íÎó£¬ÕâÀïÎÒÕýʽ¸ø´ó¼Ò˵Ã÷һϣ¬ÃâµÃ¶Ô¸÷λ¶ÁÕßÓиö²»ºÃµÄÎ󵼡£
ÎÊÌâ³öÔÚµÚ26Ò³µÄÒ»¸öͼÒÔ¼°ÆäÏà¹ØÎÄ×Ö¡£ÕâÊǵڶþÕ»ù´¡ÖªÊ¶µÄµÚÒ»½Ú£¬Æäʵ¾ÍÊǹØÓÚÄÚ´æµÄ½²½â£¬´ó¼Ò ......
[
ÕªÒª]
Ö¸ÕëÊÇ
CºÍ
C++ÓïÑÔ±à³ÌÖÐ×îÖØÒªµÄ¸ÅÄîÖ®Ò»£¬Ò²ÊÇ×îÈÝÒײúÉúÀ§»ó²¢µ¼Ö³ÌÐò³ö´íµÄÎÊÌâÖ®Ò»¡£ÀûÓÃÖ¸Õë±à³Ì¿ÉÒÔ±íʾ¸÷ÖÖÊý¾Ý½á¹¹
, ͨ¹ýÖ¸Õë¿ÉʹÓÃÖ÷µ÷º¯ÊýºÍ±»µ÷º¯ÊýÖ®¼ä¹²Ïí±äÁ¿»òÊý¾Ý½á¹¹£¬±ãÓÚʵÏÖË«ÏòÊý¾ÝͨѶ£»²¢ÄÜÏñ»ã±àÓïÑÔÒ»Ñù´¦ÀíÄÚ´æµØÖ·£¬´Ó¶ø±à³ö¾«Á·¶ø¸ßЧµÄ³ÌÐò¡£Ö¸Õ뼫´óµØ·á¸»ÁË ......
UTF-8×î´óµÄÒ»¸öÌص㣬¾ÍÊÇËüÊÇÒ»Öֱ䳤µÄ±àÂ뷽ʽ¡£Ëü¿ÉÒÔʹÓÃ1~4¸ö×Ö½Ú±íʾһ¸ö·ûºÅ£¬¸ù¾Ý²»Í¬µÄ·ûºÅ¶ø±ä»¯×Ö½Ú³¤¶È¡£
UTF-8µÄ±àÂë¹æÔòºÜ¼òµ¥£¬Ö»ÓжþÌõ£º
1£©¶ÔÓÚµ¥×ֽڵķûºÅ£¬×ֽڵĵÚһλÉèΪ0£¬ºóÃæ7λΪÕâ¸ö·ûºÅµÄunicodeÂë¡£Òò´Ë¶ÔÓÚÓ¢Óï×Öĸ£¬UTF-8±àÂëºÍASCIIÂëÊÇ ......
±¾ÎÄÖ¼ÔÚ˵Ã÷ÈçºÎÀûÓÃFlashºÍCÓïÑÔÖÆ×÷BSģʽϵÄʵʱÊý¾Ý¶¯Ì¬ÇúÏßͼ£¬ÏÖÔÚÁ÷ÐеÄʵʱÊý¾ÝÇúÏßͼ£¬´ó¶¼ÊDzÉÓÃÁËCSģʽµÄ¿ª·¢ÓïÑÔ£¬BSģʽµÄËäÓÐһЩʵÀý£¬±ÈÈçgoogleÉϵĹÉÊÐÇúÏßͼ£¬µ«ÆäʵÏֵķ½Ê½ºÍÁ÷³ÌÔÚÍøÉϺÜÉÙÄܼûµ½¡£
ÆäÔËÐÐʱµÄ½çÃæÈçÏ£¬Êý¾Ýʵʱ¸üУ¬ÇúÏßͼ´Ó×óÍùÓÒ¶¯Ì¬Òƶ¯£º
ÏÂÃæÏȽ²ÔÚʵÏÖ¹ý³ÌÖеŤ×÷»·¾³ ......