Advertisement
paulogp

token

Aug 14th, 2011
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. // apple xcode
  2. // paulogp
  3.  
  4. /* token: separacao de strings */
  5. #include <stdio.h>
  6. #include <string.h>
  7.  
  8. void token (char *the_input);
  9.  
  10. void token (char *the_input)
  11. {
  12.     the_input = strtok (the_input, " ,.-");
  13.     while (the_input != NULL)
  14.     {
  15.         printf ("%s\n", the_input);
  16.         the_input = strtok (NULL, " ,.-");
  17.     }
  18. }
  19.  
  20. int main (int argc, const char * argv[])
  21. {
  22.     char the_input[100]; // max 100 digits
  23.     char *the_input_ptr;
  24.    
  25.     printf("texto: ");
  26.     fgets(the_input, sizeof(the_input), stdin);
  27.     // removes \n from the end
  28.     // NOTE: the_file_ptr points to the_file_name
  29.     the_input_ptr = strtok (the_input, "\n");
  30.    
  31.     token (the_input_ptr);
  32.    
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement