fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main(void) {
  6. char isostr[] = "\\ISO 2022 IR 13\\\\ISO 2222 IR 31\\ISO 2022 IR 87\\";
  7. char *p = isostr;
  8. for (;;) {
  9. char *next = strchr(p, '\\');
  10. int len = next ? next-p : strlen(p);
  11. char *s = malloc(len+1);
  12. memcpy(s, p, len);
  13. s[len] = '\0';
  14. printf("--> '%s'\n", s);
  15. free(s);
  16. if (!next) break;
  17. p = next+1;
  18. }
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 2424KB
stdin
Standard input is empty
stdout
--> ''
--> 'ISO 2022 IR 13'
--> ''
--> 'ISO 2222 IR 31'
--> 'ISO 2022 IR 87'
--> ''