fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void)
  5. {
  6. char str[99];
  7. char dlm[99];
  8. char *ptr;
  9. printf("Input String:");
  10. scanf("%99s",str);
  11. printf("Delimiter String:");
  12. scanf("%99s",dlm);
  13. printf("<%s>\n",str);
  14. printf("<%s>\n",dlm);
  15. ptr = strtok(str,dlm);
  16. while(ptr != NULL){
  17. printf("%s\n",ptr);
  18. ptr = strtok(NULL,dlm);
  19. }
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5404KB
stdin
hello,apple,man
,
stdout
Input String:Delimiter String:<hello,apple,man>
<,>
hello
apple
man