Mail Archives: djgpp/1998/03/23/01:51:40
zappaz AT xtra DOT co DOT nz wrote:
>
>
> long *frequencyTable(char *namein) {
> FILE *infile;
> int c;
> long *freq; !!!!!!!!!
Thery simple ;) You just not allocate memory for freq table.
Look,
freq=(long*)calloc(255); // calloc allocates and sets memory to
zero value
if (!freq)
{ printf("Error : not enough memory! \n);
return(NULL);
}
> infile = fopen(namein,"r");
if (infile) printf("Opening %s successful.\n", namein);
// for (int i=0;i<256;i++) freq[i]=0; // not needed since we call
calloc.
> while((c=getc(infile))!=EOF)
> {
> printf("got \"%c\"\n",c); // not really neccesary
> >>> freq[c]++;
> }
> fclose(infile);
> return freq;
> }
>
--
____ ____
| \ / Dim Zegebart
____/____
Moscow Russia
WWW - http://www.geocities.com/siliconvalley/pines/7817
DZcomm - comm library for Allegro
Palantir - multitasking kernel for Allegro (based on PDMLWP)
- Raw text -