c - the following code always stuck and the window hangs -
#include<graphics.h> #include<conio.h> #include<stdlib.h> #include<dos.h> #include<alloc.h> main() { int gd = detect, gm, area, temp1, temp2, left = 25, top = 75; void far *p; initgraph(&gd,&gm,"c:\\turboc3\\bgi"); rectangle(25,75,100,100); int sz=imagesize(25,75,100,100); p=farmalloc(sz); getch(); temp1 = 200; temp2 = 200; getimage(left, top, left + 100, top + 100, p); putimage(left, top, p, xor_put); getch(); putimage(temp1 , temp2, p, xor_put); getch(); closegraph(); return 0; }
whenever execute above code compiler stucks , windows hangs. don't know how use getimage()
, putimage()
. want design tetris in c first getting hands on these functions
you have not allocated enough memory image, with
sz=imagesize(25,75,100,100); p=farmalloc(sz); ... getimage(left, top, left + 100, top + 100, p);
i suggest using image size
sz=imagesize(left, top, left + 100, top + 100);
which uses same parameters getimage()
.
Comments
Post a Comment