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¿ÉÒÔ¸ù¾ÝÓû§ËùÌṩµÄ·Ö¸î·
Ïà¹ØÎĵµ£º
Îå¡¢Îļþ¶¨Î»
¡¡¡¡ºÍCµÄÎļþ²Ù×÷·½Ê½²»Í¬µÄÊÇ£¬C++ I/Oϵͳ¹ÜÀíÁ½¸öÓëÒ»¸öÎļþÏàÁªÏµµÄÖ¸Õë¡£Ò»¸öÊǶÁÖ¸Õ룬Ëü˵Ã÷ÊäÈë²Ù×÷ÔÚÎļþÖеÄλÖã»ÁíÒ»¸öÊÇдָÕ룬ËüÏ´Îд²Ù×÷µÄλÖá£Ã¿´ÎÖ´ÐÐÊäÈë»òÊä³öʱ£¬ÏàÓ¦µÄÖ¸Õë×Ô¶¯±ä»¯¡£ËùÒÔ£¬C++µÄÎļþ¶¨Î»·ÖΪ¶ÁλÖúÍдλÖõĶ¨Î»£¬¶ÔÓ¦µÄ³ÉÔ±º¯ÊýÊÇ seekg()ºÍ seekp()£¬seekg()ÊÇ ......
ÒýÑÔ
¡¡¡¡C/C++ÓïÑÔÓÐÒ»¸ö²»Í¬ÓÚÆäËüÓïÑÔµÄÌØÐÔ£¬¼´ÆäÖ§³Ö¿É±ä²ÎÊý£¬µäÐ͵ĺ¯ÊýÈçprintf¡¢scanfµÈ¿ÉÒÔ½ÓÊÜÊýÁ¿²»¶¨µÄ²ÎÊý¡£È磺
printf ( "I love you" );
printf ( "%d", a );
printf ( "%d,%d", a, b );
¡¡¡¡µÚÒ»¡¢¶þ¡¢Èý¸öprintf·Ö±ð½ÓÊÜ1¡¢2¡¢3¸ö²ÎÊý£¬ÈÃÎÒÃÇ¿´¿´printfº¯ÊýµÄÔÐÍ£º
int printf ( const ......
±¾ÎÄÖ¼ÔÚ˵Ã÷ÈçºÎÀûÓÃFlashºÍCÓïÑÔÖÆ×÷BSģʽϵÄʵʱÊý¾Ý¶¯Ì¬ÇúÏßͼ£¬ÏÖÔÚÁ÷ÐеÄʵʱÊý¾ÝÇúÏßͼ£¬´ó¶¼ÊDzÉÓÃÁËCSģʽµÄ¿ª·¢ÓïÑÔ£¬BSģʽµÄËäÓÐһЩʵÀý£¬±ÈÈçgoogleÉϵĹÉÊÐÇúÏßͼ£¬µ«ÆäʵÏֵķ½Ê½ºÍÁ÷³ÌÔÚÍøÉϺÜÉÙÄܼûµ½¡£
ÆäÔËÐÐʱµÄ½çÃæÈçÏ£¬Êý¾Ýʵʱ¸üУ¬ÇúÏßͼ´Ó×óÍùÓÒ¶¯Ì¬Òƶ¯£º
ÏÂÃæÏȽ²ÔÚʵÏÖ¹ý³ÌÖеŤ×÷»·¾³ ......
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 ......