here is the problem
for example
in = "a b\nab c\ndd";
out = "a b\nb c\ndd"
Here is my C code
while(c=getchar()!=EOF){
if(c==' '){
while( (c1=getchar()) == ' '); // ignore all other contiguous blank
putchar(c); // output one blank
putchar(c1); // output the next non-blank character
}
else putchar(c);
}
Can I have an implementation with shrinked size?
Assuming you remove only
' ':You can change it to check for any white space with a simple macro:
and replace the
c == ' 'with it