strtok_r.c 492 B

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