实现非常简单: char * strtok_r(char * str,const char * delim,char ** nextp) { char * ret; if(str == NULL) str = * nextp; str + = strspn(str,delim); if(* str ==''\''') 返回NULL; ret = str; str + = strcspn(str,delim); if(* str) * str ++ =' '\0''; * nextp = str; 返回ret; } - Chqrlie。strtok_r takes an extra parameter, q pointer to a char * where it stores itscurrent state.The implementation is quite straightforward:char *strtok_r(char *str, const char *delim, char **nextp){char *ret;if (str == NULL)str = *nextp;str += strspn(str, delim);if (*str == ''\0'')return NULL;ret = str;str += strcspn(str, delim);if (*str)*str++ = ''\0'';*nextp = str;return ret;}--Chqrlie. 这篇关于strtok和strtok_r的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 20:38