Hey im writing a programme that gets a string, and stores in in an array and then outputs each word on a single line, with no spaces and no blank lines.
So far i have this:
This works perfectly until someone puts in a double space, and then it will output a blank line, i have tried many things so it will not out put a blank line but cant seem to get anywhere.Code:char line[100]; int i; printf("Enter a line of text (max of 100 chars): ", line); gets(line); for(i = 0; line[i]!='\0'; i++) {if(line[i]!=' ' ) putchar(line[i]); else printf("\n"); } printf("\n"); }
Can someone please help.
Thanks Trueman