Berikut merupakan program untuk baca file dan menghitung jumlah karakter
FILE *in;
void BACA( int[ ] );
void CETAK( int[ ] );
int main() {
int tabel[26] = {0};
BACA(tabel);
CETAK(tabel);
}
void BACA ( int huruf[] ) {
char c;
if (( in = fopen("COBA.TXT" , "r")) == NULL)
printf ("File tidak bisa dibaca\n");
else
while ( (c = fgetc(in)) != EOF ) {
c = ( (( c >= 97) || ( c <= 122)) ? c - 32 : c );
if ( (c >= 65) || (c <= 90) )
++huruf [ c - 65 ];
}
fclose(in);
}
void CETAK ( int huruf[] ) {
int counter;
for ( counter = 0 ; counter <= 25 ; counter++ )
printf ("\n%c%5d", counter + 65, huruf[counter] );
}