Created
May 28, 2016 00:10
-
-
Save innerspirit/e78ad9b3de7c4f01dcb1822a14bd9269 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ctype.h> | |
int main() { | |
FILE *arch; | |
// inicializar el primero en 0 hace | |
// que se inicialice el resto en 0 tambien | |
int i,v[26]={0}; | |
char c,cad[256]; | |
arch=fopen("notas.txt","rt"); | |
if(arch==NULL) { | |
puts("No se puede abrir el archivo"); | |
return 1; | |
} | |
fgets(cad,256,arch); | |
while(!feof(arch)) { | |
for (i = 0; cad[i]; ++i) | |
{ | |
c=toupper(cad[i]); | |
if (isalpha(c)) | |
{ | |
// resta el valor ASCII 65 (A) | |
v[c-'A']++; | |
} | |
fgets(cad,256,arch); | |
} | |
fclose(arch); | |
} | |
for (i = 0; i < 26; ++i) | |
{ | |
printf("La letra %c se repite %d veces\n",i+'A',v[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment