dimanche 15 avril 2018

my code dosen't return at the end of the main function

I wrote this program that works fine but the return 0 statement doesn't work. Instead it just prints out the first input. Can someone help me out?

#include < stdio.h >
int c;
int main(){
while ((c = getchar()) != EOF) {
    if (c != ' ') {
        putchar(c);
    } else {
        c = getchar();
        if (c == EOF) {
            putchar(' ');
        } else if (c == ' ') {
            c = getchar();
            if (c == EOF) {
                putchar(' ');
                putchar(' ');
            } else if (c == ' ') {
                putchar('x');
            } else {
                putchar(' ');
                putchar(' ');
                putchar(c);
            }

        } else {
            putchar(' ');
            putchar(c);
        }
    }
    return 0;
}

}

Aucun commentaire:

Enregistrer un commentaire