I'm relatively new to C programming, and I have a pretty trivial question.
I'm trying to convert all whitespace characters from standard in to a single space. I understand that my code won't work as '\n' will be read character by character and not as a whole.
How might I change this to interpret '\n' and others like '\t' as a single whitespace character?
Thanks.
Code:#include<stdio.h> #include<ctype.h> #include<string.h> int main(){ int c; c = getchar(); while(c != EOF){ if(isspace(c)) c = ' '; putchar(c); c = getchar(); } return 0; }



LinkBack URL
About LinkBacks


