How do I make many consecutive white spaces into one white space? I tried this:
which works, but is it the most efficient way to write it? Or is there at least a better way of doing this?Code:int c, last_c = '\0'; while( (c=getchar()) != EOF ){ if( !isspace(c) && isspace(last_c) ) putchar(' '); if( !isspace(c) ) putchar(c); last_c = c; }