Exercise# 1.5.2 - Character Count

alendr · updated September 15, 2021 · C
#include <stdio.h>
/* count characters in input; 1st version */ 

int main() {
    long nc; 
    nc = 0; 
    while (getchar() != EOF) 
        ++nc;  
    printf("%1d\n", nc); 
}

Comments

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