strtok_r.c 480 B

123456789101112131415161718
  1. #include <string.h>
  2. #include <stdio.h>
  3. int main(void) {
  4. char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, "
  5. "is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.\n";
  6. char* sp;
  7. char* token = strtok_r(source, " ", &sp);
  8. while (token) {
  9. printf("%s", token);
  10. if ((token = strtok_r(NULL, " ", &sp))) {
  11. printf("_");
  12. }
  13. }
  14. return 0;
  15. }