Programming - cpueblo.com

strtok 함수 예제


글쓴이 : 유광희 날짜 : 2002-05-22 (수) 11:21 조회 : 8658
StrTok 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 ); token = strtok( string, seps ); while( token != NULL ) { printf( " %s\\n", token ); token = strtok( NULL, seps ); } } Output A string of ,,tokens and some more tokens Tokens: A string of tokens and some more tokens