#include #include #include #define MAX_SIZE 256 //ファイルを1回に読む最大量 int make_huff(FILE*,struct node*); struct node{ struct node *right; struct node *left; char obj; }; struct node *top; int main(void) { char f_name[256]; FILE *fp; struct node item[30]; printf("File name(alphabet only) -->"); scanf("%s",f_name); fp = fopen(f_name,"r"); if(fp == NULL){ printf("File input error\n"); exit(-1); } make_huff(fp,item); //Σ(・▽・Σ(・▽・Σ(・▽・Σ(・▽・Σ(・▽・Σ(・▽・ return 0; } int make_huff(FILE *fp,struct node *item) { int a_num[26],i; char ch; for(i = 0; i < 26;i++) a_num[i] = 0; while((ch = fgetc(fp)) != EOF) a_num[ch - 'a']++; //aはa_num[0]、bはa_num[1]....、zはa_num[25] を++する。 a はAlphabetの略なんだからねっ! for(i = 0; i < 26;i++){ printf("%c = %d\n",'a'+i, a_num[i]); } return 0; }