Turbo - C
Scott M Glen CS89
sglen at cs.strath.ac.uk
Thu Mar 21 21:16:34 AEST 1991
Can anyone tell my why the following Turbo-c code causes a crash. (I am using
Turbo-c V2, on an NTS PC).
Basically it's a trivial piece of code, to save a small rectangular area of
the screen to memory, write something in the area (in this case a black
rectangle) and then restore the screen to its original status.
void
help_option1 (void)
{
int i;
void *buffer;
unsigned size;
size=imagesize(0,0,20,20); /* define rectangle to be saved */
if (size!=-1) /* if area is too large imagesize returns -1 */
{
buffer=malloc (size); /* allocate memory for area of screen */
getimage (0,0,20,20);
setfillstyle (SOLID_FILL,BLACK);
bar (0,0,20,20); /* black out the rectangle */
i=getch(); /* wait for a key */
putimage (0,0,buffer,COPY_PUT); /* restore rectangle
free (buffer);
}
else
{
/* image too large */
}
}
When it runs, the black box apewars as expected, but then the screen freezes
I don't even know whether the problem lies with saving the area, or restoring
it.
Any help would be very much appreciated.....
******************************************************************************
* *
* Scott Glen *
* 3rd Year Computer Science *
* The University Of Strathclyde *
* Glasgow *
* Scotland *
* *
* cadx830 at uk.ac.strathclyde.computer-centre-sun *
* sglen at uk.ac.strathclyde.cs *
* *
******************************************************************************
More information about the Comp.lang.c
mailing list