Exercise #1-6

alendr · updated September 15, 2021 · C
#include <stdio.h>
/* While getchar has a character - 1 is assigned to 'c'. 
    As soon as EOF is encountered - 0 is assigned &a While loop ends. */ 
int main()
{
    int c;
    while (c = getchar() != EOF)
        printf("%d\n", c); 
        
    printf("%d - at EOF\n", c); 
    
    return 0;
}

Comments

Please sign up or log in to contribute to the discussion.