Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main (void) {
- char c[] = "I - need - to - do - this - break",
- *p = c;
- int in = 0;
- while (*p) {
- if (*p == ' ' || *p == '-') {
- if (in) {
- char current = *p;
- *p = 0;
- puts (c);
- *p = current;
- }
- in = 0;
- }
- else {
- in = 1;
- }
- p++;
- }
- if (in)
- puts (c);
- }
- $ ./bin/incremental
- I
- I - need
- I - need - to
- I - need - to - do
- I - need - to - do - this
- I - need - to - do - this - break
Add Comment
Please, Sign In to add comment