Message-ID: <3516069A.40AF@post.comstar.ru> Date: Mon, 23 Mar 1998 09:52:10 +0300 From: Dim Zegebart Reply-To: zager AT post DOT comstar DOT ru Organization: Comstar Ltd. MIME-Version: 1.0 To: zappaz AT xtra DOT co DOT nz CC: DJGPP Mail List Subject: Re: Why why why??? (help me with this code....) References: <6f0c4b$a9p$1 AT wolfman DOT xtra DOT co DOT nz> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk 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)