Mail Archives: djgpp/1997/12/29/22:49:42
On Mon, 29 Dec 1997 00:58:33 +0100, Rune Lanton
<please DOT mail DOT me AT usa DOT net> wrote:
->#include <stdio.h>
->
->void main(arg_counter, arg_pointers)
->int arg_counter;
->char *arg_pointers[];
->{
->
->FILE *file_pointer;
->char *file_buffer;
->int file_number;
->long int file_size;
->unsigned char end_of_file;
->char *search_word_ptr;
->char *text_ptr;
->long int word_match;
->long int a,b,c,d;
->int search_word_length;
->long int mid_match;
->char *e;
->
->file_pointer = fopen(arg_pointers[1], "rb");
->
->file_number = fileno(file_pointer);
->file_size = (filelength(file_number)) + 256;
->*file_buffer = malloc((file_size)+512);
->
->fread(file_buffer, 1, file_size, file_pointer); <----- This is were
->it crashes!!!!
->fclose(file_pointer);
>
Hi;
I think the problem lays with the read, tryimg to read 256 bytes
past the end of the file.
Try
fread(file_buffer, 1, file_size-256, file_pointer);
- Raw text -