Including new lines in string input

I'm writing a program that deblanks an input.

example

"This is a sentence."
becomes
"Thisisasenctence."

I am scanning in the characters one at a time, then checking if the character is white space. If it isn't white space, I print it, otherwise I'm skipping over it.

If I'm thinking correctly, the error is in my do-while loop where I'm checking for the end of the input. What should I use instead of '\n' if I want the user to be able to print multiple lines?

1
2
3
4
5
6
7
8
9
10
11
12
13
int main(){
    int c;
    do{
        c=getchar();
        if(isspace(c)){}
        else{
            printf("%c",c);
        }
        
    }while(c!='\n');
    system("pause");
    return 0;    
}
Topic archived. No new replies allowed.