以下代码始终被卡住,窗口挂起 #包括 #包括 #包括 #包括 #包括 main() { int gd=DETECT,gm,area,temp1,temp2,left=25,top=75; void far*p; initgraph(&gd,&gm,“C:\\TurboC3\\BGI”); 矩形(25,75100100); int sz=图像大小(25,75100100); p=法马洛克(sz); getch(); temp1=200; temp2=200; getimage(左、上、左+100、上+100、p); putimage(左、上、p、XOR_PUT); getch(); putimage(temp1、temp2、p、XOR_PUT); getch(); closegraph(); 返回0; }
每当我执行上述代码时,编译器就会停止运行,windows也会挂起。我不知道如何正确使用以下代码始终被卡住,窗口挂起 #包括 #包括 #包括 #包括 #包括 main() { int gd=DETECT,gm,area,temp1,temp2,left=25,top=75; void far*p; initgraph(&gd,&gm,“C:\\TurboC3\\BGI”); 矩形(25,75100100); int sz=图像大小(25,75100100); p=法马洛克(sz); getch(); temp1=200; temp2=200; getimage(左、上、左+100、上+100、p); putimage(左、上、p、XOR_PUT); getch(); putimage(temp1、temp2、p、XOR_PUT); getch(); closegraph(); 返回0; },c,C,每当我执行上述代码时,编译器就会停止运行,windows也会挂起。我不知道如何正确使用getimage()和putimage()。我想用c语言设计俄罗斯方块,所以首先要掌握这些功能,因为没有为图像分配足够的内存 #include<graphics.h> #include<conio.h> #include<stdlib.h> #include<dos.h> #include<alloc.h> main() {
getimage()
和putimage()
。我想用c语言设计俄罗斯方块,所以首先要掌握这些功能,因为没有为图像分配足够的内存
#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;
}
我建议使用这个来获得图像大小
sz=imagesize(25,75,100,100);
p=farmalloc(sz);
...
getimage(left, top, left + 100, top + 100, p);
它使用了与
getimage()
相同的参数,现在系统不会挂起,但编译器会挂起。你能给我完整的代码吗?不,对不起,我不能,因为我没有为看起来像是Borland代码的东西安装编译器。但我感到困惑:你的问题是“编译器死机,windows挂起”。如果编译器失败,怎么会有可执行文件?现在你说的是“编译器[挂起]”。有什么不同?你问对问题了吗?很抱歉让你困惑。但我实际上是在告诉你发生了什么或者我在观察。好的,谢谢,现在我已经解决了这个问题。我不知道怎么写,但我重新编写了整个代码,并做了一些修改,它成功了。
sz=imagesize(left, top, left + 100, top + 100);