| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 653 人关注过本帖
标题:第一次接触graphic.h,运行程序时出错
只看楼主 加入收藏
Soulofghost
Rank: 1
等 级:新手上路
帖 子:10
专家分:5
注 册:2008-8-10
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
第一次接触graphic.h,运行程序时出错
图片附件: 游客没有浏览图片的权限,请 登录注册


代码如下:
程序代码:
#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;
   char xrange[80], yrange[80];

   /* initialize graphics and 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("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   midx = getmaxx() / 2;
   midy = getmaxy() / 2;

   /* convert max resolution values into strings */
   sprintf(xrange, "X values range from 0..%d", getmaxx());
   sprintf(yrange, "Y values range from 0..%d", getmaxy());

   /* display the information */
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   outtextxy(midx, midy, xrange);
   outtextxy(midx, midy+textheight("W"), yrange);

   /* clean up */
   getch();
   closegraph();
   return 0;
} 


还有一个问题,我是新手,电脑这方面的知识几乎都是我自学的,当我看完了C primer plus这本书和其他一些关于C的书籍,之后又大致学习了一下C++,现在我不知道应该怎么继续了。我觉得我应该多找一些练习来做,并多学习一些其他的知识。大家有什么意见么?
我的目标是参加2010年的Canadian Computer competition, http://www.cemc.uwaterloo.ca/contests/past_contests.html#ccc
junior的看上去并不是很难,可是感觉还是缺许多知识与练习,我希望大家可以帮助我

[[it] 本帖最后由 Soulofghost 于 2009-8-5 10:55 编辑 [/it]]
搜索更多相关主题的帖子: 运行 graphic 
2009-08-05 10:54
zhaoguoge
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:46
专家分:121
注 册:2009-7-8
收藏
得分:20 
graphic.h的问题我也遇到过。好象是编译器运行平台问题。我用TC2.0解决了部分问题。
2009-08-05 11:45
Soulofghost
Rank: 1
等 级:新手上路
帖 子:10
专家分:5
注 册:2008-8-10
收藏
得分:0 
我用的就是TC2.0
2009-08-05 13:00
encode
Rank: 1
来 自:这个世界很黑暗!!
等 级:新手上路
帖 子:17
专家分:3
注 册:2009-10-3
收藏
得分:0 
装个虚拟机,似乎可以解决
2009-10-04 01:43
快速回复:第一次接触graphic.h,运行程序时出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012034 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved