Guest User

Untitled

a guest
Feb 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main (void) {
  4.  
  5. char c[] = "I - need - to - do - this - break",
  6. *p = c;
  7. int in = 0;
  8.  
  9. while (*p) {
  10. if (*p == ' ' || *p == '-') {
  11. if (in) {
  12. char current = *p;
  13. *p = 0;
  14. puts (c);
  15. *p = current;
  16. }
  17. in = 0;
  18. }
  19. else {
  20. in = 1;
  21. }
  22. p++;
  23. }
  24.  
  25. if (in)
  26. puts (c);
  27. }
  28.  
  29. $ ./bin/incremental
  30. I
  31. I - need
  32. I - need - to
  33. I - need - to - do
  34. I - need - to - do - this
  35. I - need - to - do - this - break
Add Comment
Please, Sign In to add comment