c ×Ö·û´®´¦Àíº¯Êý strtok Ô´Âë
/***
*strtok.c - tokenize a string with given delimiters
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines strtok() - breaks string into series of token
* via repeated calls.
*
*******************************************************************************/
#include
#include
#ifdef _SECURE_VERSION
#include
#else /* _SECURE_VERSION */
#include
#endif /* _SECURE_VERSION */
/***
*char *strtok(string, control) - tokenize string with delimiter in control
*
*Purpose:
* strtok considers the string to consist of a sequence of zero or more
* text tokens separated by spans of one or more control chars. the first
* call, with string specified, returns a pointer to the first char of the
* first token, and will write a null char into string immediately
* following the returned token. subsequent calls with zero for the first
* argument (string) will work thru the string until no tokens remain. the
* control string may be different from call to call. when no tokens remain
* in string a NULL pointer is returned. remember the control chars with a
* bit map, one bit per ascii char. the null char is always a control char.
*
*Entry:
* char *string - string to tokenize, or NULL to get next token
* char *control - string of characters to use as delimiters
*
*Exit:
* returns pointer to first token in string, or if string
* was NULL, to next token
* returns NULL when no more tokens remain.
*
*Uses:
*
*Exceptions:
*
*******************************************************************************/
#ifdef _SECURE_VERSION
#define _TOKEN *context
#else /* _SECURE_VERSION */
#define _TOKEN ptd->_token
#endif /* _SECURE_VERSION */
#ifdef _SECURE_VERSION
char * __cdecl strtok_s (
char * string,
const char * control,
char ** context
)
#else /* _SECURE_VERSION */
char *
Ïà¹ØÎĵµ£º
extern "C"°üº¬Ë«Öغ¬Ò壬ÆäÒ»£º±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ£»Æä¶þ£º±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ¡£
1£©±»extern “C”ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵ģ»
externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×Ö£¬¸Ã¹Ø¼ü×Ö¸æËß±àÒëÆ÷£¬ÆäÉùÃ÷µÄº¯ÊýºÍ±äÁ¿¿É ......
CÖÐÔ¤±àÒëºê¶¨Òå
2010-01-07 11:49
ÔÚ½«Ò»¸öCÔ´³ÌÐòת»»Îª¿ÉÖ´ÐгÌÐòµÄ¹ý³ÌÖÐ, ±àÒëÔ¤´¦ÀíÊÇ×î³õµÄ²½Öè. ÕâÒ»²½ÖèÊÇÓÉÔ¤´¦ÀíÆ÷(preprocessor)À´Íê³ÉµÄ. ÔÚÔ´Á÷³ÌÐò±»±àÒëÆ÷´¦Àí֮ǰ, Ô¤´¦ÀíÆ÷Ê×ÏȶÔÔ´³ÌÐòÖеÄ"ºê(macro)"½øÐд¦Àí.
C ³õѧÕß¿ÉÄܶÔÔ¤´¦ÀíÆ÷ûʲô¸ÅÄî, ÕâÊÇÇéÓпÉÔµÄ: Ò»°ãµÄC±àÒëÆ÷¶¼½«Ô¤´¦Àí, »ã±à, ± ......
ÖÚ¶àC++Êé¼®¶¼ÖÒ¸æÎÒÃÇCÓïÑÔºêÊÇÍò¶ñÖ®Ê×£¬µ«ÊÂÇé×ܲ»ÈçÎÒÃÇÏëÏóµÄÄÇô»µ£¬¾ÍÈçͬgotoÒ»Ñù¡£ºêÓÐ
Ò»¸öºÜ´óµÄ×÷Ó㬾ÍÊÇ×Ô¶¯ÎªÎÒÃDzúÉú´úÂë¡£Èç¹û˵ģ°å¿ÉÒÔΪÎÒÃDzúÉú¸÷ÖÖÐͱðµÄ´úÂë(ÐͱðÌæ»»)£¬
ÄÇôºêÆäʵ¿ÉÒÔΪÎÒÃÇÔÚ·ûºÅÉϲúÉúеĴúÂë(¼´·ûºÅÌæ»»¡¢Ôö¼Ó)¡£
¹ØÓÚºêµÄһЩÓï·¨ÎÊÌ⣬¿ÉÒÔÔÚgoogleÉÏÕÒµ½¡£ÏàÐÅÎÒ£¬Äã ......
¶ÔÒ°Ö¸ÕëµÄһЩÈÏʶ£º
ÎÒ¶ÔÒ°Ö¸ÕëµÄÈÏʶ£¬ÎÒ¾õµÃÒ°Ö¸Õë¾ÍÊÇÒ»¸öÖ¸Õë±äÁ¿ËüÀïÃæµÄÖµÊDz»È·¶¨µÄ£¬ÕâÑùµ±Äã²Ù×÷Õâ¸ö±äÁ¿ËùÖ¸¶¨µÄÄÚ´æµØÖ·µÄʱºò£¬¾Í»á´øÀ´Ò»Ð©²»È·¶¨µÄÒòËØ£¬ÄÃÒ»¸ö±È½Ï³£¼ûµÄÎÊÌâÀ´¾Ù¸öÀý×ÓÀ´ËµÃ÷һϣº
¿´ÏÂÃæ´úÂ룺
int a = 10;
int *p;
*p = a;
1. ......
ºÜÓвο¼ÒâÒåµÄѧÀúÁ÷³Ì¡£
¡¡¡¡1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC.
¡¡¡¡´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû³ÉΪһ¸ö½â¾öÎÊÌâµÄר¼Ò¡£×öÒ»¸öÓÐÓõijÌÐòÔ±£¬×öÒ»¸ö׬ǮµÄ³ÌÐòÔ±¡£ÎÒÃǵļÛÖµ£¬½«ÌåÏÖÔÚ¿Í»§¼ÛÖµÉÏ£¬¶ø²»ÊÇÓïÑÔдµÃºÃ²»ºÃ¿´¡£
¡¡¡¡C++ÊÇCµÄÒ»¸öÃæÏò¶ÔÏóµÄ½âÊÍ£¬C++ΪCÀ ......