fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main ()
  5. {
  6. char buffer[128];
  7. char *str ="This is a long text \r\n with \r\nmany carriage returns,\
  8. I hate \r\n just this\r\n nothing else\r\n";
  9.  
  10. char *token="\r\n";
  11.  
  12. int l=strlen(str);
  13. char *start,*p;
  14. start=str;
  15.  
  16. p= strstr (str,token);
  17. while(p)
  18. {
  19. strncpy( buffer,str, p-str);
  20. buffer[p-str] ='\0';
  21. printf("%s\n",buffer);
  22. str=p+strlen(token);
  23. if((str-start) >= l)
  24. break;
  25. p= strstr (str,token);
  26. }
  27. if(!p)
  28. printf("%s\n",str);
  29. return 0;
  30. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
This is a long text 
 with 
many carriage returns,  I hate 
 just this
 nothing else