Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

John Edgar Congote Calle http://jcongote.blogspot.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Conteo de caracteres

Este pedazo de codigo cuenta los caracteres de un archivo

this code count the chars of a file.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    int cont[257];
    int t;
    FILE *ent;
    
    for (t=0;t<257;t++)
        cont[t]=0;
      
    ent=fopen("input.txt","r");
//    printf("Se abrio el archivo :P\n");
    do {
        t = fgetc(ent);
        cont[t]++;
    } while (!feof(ent));
    fclose(ent);

    for (t=0;t<257;t++){
        printf("Caracter %i se repitio %i veces\n", t, cont[t]);
    }

    
//  system("PAUSE");	
  return 0;
}

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS