| 发表于:2007-07-06 10:45:527楼 得分:10 |
msdn里的: example /* strtok.c: in this program, a loop uses strtok * to print all the tokens (separated by commas * or blanks) in the string named "string ". */ #include <string.h> #include <stdio.h> char string[] = "a string\tof ,,tokens\nand some more tokens "; char seps[] = " ,\t\n "; char *token; void main( void ) { printf( "%s\n\ntokens:\n ", string ); /* establish string and get the first token: */ token = strtok( string, seps ); while( token != null ) { /* while there are tokens in "string " */ printf( " %s\n ", token ); /* get next token: */ token = strtok( null, seps ); } } output a string of ,,tokens and some more tokens tokens: a string of tokens and some more tokens | | |
|