Advertisement
AntonioVillanueva

Tokens strtok

Jan 20th, 2023
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. /*Separar por Tokens con strtok A.Villanueva
  2. * char *strtok(char *str, const char *delim)
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8.  
  9. int main() {
  10.     char * token;
  11.     char str[] = "- Alguien volo,sobre el nido del cuco. -";
  12.     const char * sep = " ,.-!";//Separadores
  13.  
  14.     token = strtok ( str, sep );//Primer token
  15.  
  16.     while( token != NULL ) {//Recorro los tokens
  17.         printf( " %s\n", token );
  18.         token = strtok(NULL, sep);
  19.     }
  20.  
  21.     return EXIT_SUCCESS;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement