/* 練習7-2は、List7-4とList7-5を元にして作るとよい * count.c */ #include #include /* isupper()やtolower()を使う */ int main(void); int main(void) { int c; long Nupper = 0L, Nlower = 0L, Nalpha = 0L, Nspace = 0L; while ( ( c = getchar() ) != EOF ) { if ( isupper(c) ) { Nupper++; Nalpha++; } else if ( islower(c) ) { Nlower++; Nalpha++; } else if ( isspace(c) ) Nspace++; } printf("uppercase = %ld\n", Nupper); printf("lowercase = %ld\n", Nlower); printf("alphabet = %ld\n", Nalpha); printf(" space = %ld\n", Nspace); return 0; }