fork download
  1. // C program to demonstrate working of strtok_r()
  2. // by splitting string based on space character.
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. int main()
  7. {
  8. char str[] = "Geeks for Geeks";
  9. char* token;
  10. char* rest = str;
  11.  
  12. while ((token = strtok_r(rest, " ", &rest)))
  13. printf("%s\n", token);
  14.  
  15. return (0);
  16. }
Success #stdin #stdout 0s 5316KB
stdin
45
stdout
Geeks
for
Geeks