#include <string.h> char *strtok( char *str1, const char *str2 ); åè½ï¼å½æ°è¿åå符串str1ä¸ç´§æ¥âæ è®°âçé¨åçæé, å符串str2æ¯ä½ä¸ºæ è®°çåé符ãå¦æåéæ 记没ææ¾å°ï¼å½æ°è¿åNULLã为äºå°å符串转æ¢ææ è®°ï¼ç¬¬ä¸æ¬¡è°ç¨str1 æåä½ä¸ºæ è®°çåé符ãä¹åæ以çè°ç¨str1 é½åºä¸ºNULLã
ä¾å¦:
char str[] = "now # is the time for all # good men to come to the # aid of their country"; char delims[] = "#"; char *result = NULL; result = strtok( str, delims ); while( result != NULL ) { printf( "result is \"%s\"\n", result ); result = strtok( NULL, delims ); } 以ä¸ä»£ç çè¿è¡ç»ææ¯ï¼
result is "now " result is " is the time for all " result is " good men to come to the " result is " aid of their country" ç¸å
³ä¸»é¢:
温馨提示:答案为网友推荐,仅供参考