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¿ÉÒÔ¸ù¾ÝÓû§ËùÌṩµÄ·Ö¸î·
Ïà¹ØÎĵµ£º
½ñÌì¿´µ½Ò»ÖֱȽϰ²È«µÄö¾Ùд·¨£¡
enum example
{
item1 = 0,
item2,
item3,
item4,
item5,
max /* when you want to add element,please add before this */
};
µ±ÄãʹÓÃËüµÄʱºò£º
example ex1;
i ......
×ªÔØ×Ô: http://bbs.chinaitlab.com/thread-304041-1-1.html
ѧϰCÓïÑÔ²»ÊÇÒ»³¯Ò»Ï¦µÄÊÂÇ飬µ«Ò²²»ÐèÒª»¨·ÑÊ®Äêʱ¼ä²ÅÄܾ«Í¨¡£ÈçºÎÒÔ×îСµÄ´ú¼Ûѧϰ²¢¾«Í¨CÓïÑÔÊDZ¾ÎĵÄÖ÷Ìâ¡£Çë×¢Ò⣬¼´Ê¹ÊÇ“×îСµÄ´ú¼Û”£¬Ò²¾ø²»ÊÇʲô½Ý¾¶£¬¶øÊÇÒÔ×î¶ÌµÄʱ¼äÈ¡µÃ×î¶àµÄÊÕ»ñ£¬Í¬Ê±Ò²Òâζ×ÅÄãÐèÒª¾Àú¼è¿àµÄ¹ý³Ì¡£
Ò»¡¢Òª¶Á ......
ͨ¹ýÇ°ÃæÁ½Æª£¬ÏàÐÅ´ó¼ÒÒѾ»ù±¾Á˽âÁËÎÒÃǵÄÑо¿Ë¼Â·¡£¼ÈÈ»ÊÇÑо¿£¬ÄÇô±ØÐëµÄÑо¿¹¤¾ß¾ÍµÃÊìÁ·ÕÆÎÕÁË¡£ÕâÀïÎÒËùÖ¸µÄÑо¿¹¤¾ß¾ÍÊÇVC£¬ÎÒËùʹÓõÄVC°æ±¾ÊÇ2005¡£±¾ÎÄÒ²½«¸ù¾ÝVC2005½øÐÐ̽ÌÖ¡£¿ÉÄܺܶàÅóÓÑ»òÕß³õѧÕß»¹ÊÇʹÓõÄVC6.0¡£ÔÚÕâÀï±¾È˲»ÍƼöʹÓÃVC6.0¡£ÔÒòºÜ¼òµ¥£¬VC6.0ÒѾ¹ýʱÁË£¬ºóÃæµÄ°æ±¾±ÈVC6.0¸üÇ¿´ó·½±ã ......
http://docs.google.com/View?docid=ajbgz6fp3pjh_2dwwwwt#_38239340844832237
It is not about optimization.
The whole idea of using 'do/while' version
is to make a macro which will
expand into a regular statement, not into a
compound statement. This is
done in order to make the use of function-s ......