广东商学院校园风在线's Archiver

无人性 发表于 2007-12-28 13:43

急啊,C语言图形模式,要课程设计啊!!

现在要课程设计啦,但是我在TC2.0输入图形模式时(代码如下),只是一片黑,什么也看不到(说明一下,不进入图形模式,背景和字体的颜色是正常的),:Q 过了几秒就出现了下面的对话框,那位高手帮忙啊!!!!!!


#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy, i;
   /* initialize graphics, local variables */
   initgraph(&gdriver, &gmode, "");
   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("p    ress any key to halt:");
      getch();
      exit(1); /* terminate with error code */
   }
   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
   /* loop through the fill patterns */
   for (i=EMPTY_FILL; i<USER_FILL; i++)
   {
      /* set the fill style */
      setfillstyle(i, getmaxcolor());
      /* draw the 3-d bar */
      bar3d(midx-50, midy-50, midx+50, midy+50, 10, 1);
      getch();
   }
   /* clean up */
   closegraph();
   return 0;
}

[[i] 本帖最后由 无人性 于 2007-12-28 13:49 编辑 [/i]]

DarkClouds 发表于 2007-12-28 23:27

int gdriver = DETECT, gmode, errorcode;

整型可以直接搞个DETECT就上去?

无人性 发表于 2007-12-29 12:54

是啊,这是图形模式的调用啊,不是这样,那正确的写法是怎么样????

DarkClouds 发表于 2007-12-29 17:50

回复 3# 的帖子

查了一下,确实是这样写的.
你试着把你的代码拿到别人得机子上试试.
估计是命令集里面没有图形库里的某个命令吧

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.