c语言分割字符串-----(strtok)

int main(void) {

  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( "%s\n", result );          

result = strtok( NULL, delims );   }    

  

system("pause");   

return 0;

}

//结果输出: now  is the time for all  good men to come to the  aid of their country

posted @ 2014-03-05 20:07  Blue-Dream  阅读(234)  评论(0)    收藏  举报