mercredi 22 avril 2015

What does this program do? (Self calling main function + getchar)

Can anybody help me explain this question from a past exam paper? When I compile it, it is never satisfied with any input. Also, what is the reason for the self calling main function?

What does the following program do? Justify your answer.

#include <stdio.h>
int main ( void ) {
    int c;
    if (( c = getchar() ) != EOF) {
        main();
        printf("%c", c);
    }
    return 0; 
}

Aucun commentaire:

Enregistrer un commentaire