Buenos días.
Alguien sabría decirme para que se usa y cómo se usa el código strtok?
no está mal usar google antes de preguntar...
busqué strtok en google y el tercer resultado es esto
https://es.stackoverflow.com/questions/29469/funcionamiento-del-strtok-y-strcmp (https://es.stackoverflow.com/questions/29469/funcionamiento-del-strtok-y-strcmp)
lo explican muy bien y detallado
Imagínate que strtok esta construida así (no es realmente así pero sirve para que veas como podría funcionar):
char* mi_strtok(char *str, const char *delim) {
char *ret_dir;
static char *intermedio;
static char *fin;
if(str) {
ret_dir = str;
fin = str+strlen(str)+1;
}
else
ret_dir = intermedio+1;
if(ret_dir >= fin)
return NULL;
intermedio = strpbrk(ret_dir, delim);
if(intermedio)
*intermedio = '\0';
else
intermedio = fin;
return ret_dir;
}