Hi,
This should be an easy one, needless to say I don't know it
I've made a small program that allocates a 64,000 byte buffer, reads data from a file into it and then opens another file and writes it. However, after compiling it in Turbo C++ 3.0 and then running it, Windows catches a general protection fault (a crash in real DOS). The problem is, I'm not sure why...
Here's the code:-
The actual program won't always allocate 64,000 bytes each time, so a static buffer isn't the answer. I have a feeling I'm misusing pointers here. Any ideas?Code:#include <stdio.h> int main(void) { FILE *fp; unsigned char *screen; fp = fopen("image", "rb"); screen = (unsigned char *)malloc(64000); fread(screen, 64000, 1, fp); fclose(fp); fp = fopen("data.raw", "wb"); fwrite(screen, 64000, 1, fp); fclose(fp); return(0); }



LinkBack URL
About LinkBacks




).