第一次接触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]]






