无法打开包含文件:'graphics.h':没有这样的文件或目录

发布于 2024-11-06 19:02:05 字数 4465 浏览 5 评论 0原文

我在 C++ 中使用 #include "graphics.h"

我使用 Visual Studio 2008 作为我的 IDE。

问题是我无法构建我的代码。

这是我的代码...

#include<stdio.h>
#include<conio.h>
#include "graphics.h"
#include<stdlib.h>
#include<dos.h>

char game[3][3];
void screen(void);
void introducing(void);
void input(void);
void circle(int,int);
void cross(int,int);

void main(void)
{
int gd=DETECT, gm, errorcode;   /* request auto detection */
char msg[80];
initgraph(&gd,&gm,"\\tc\\bgi"); /* initialize graphics */
errorcode = graphresult();      /* read result of initialization */
if(errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
cleardevice();
introducing();
getche();
cleardevice();
screen();
getche();
closegraph();
}


void introducing(void)                   /*introduction of the project*/
{
    setbkcolor(5);
    int loop;
    setcolor(1);
    int r,c;
    settextstyle(5,0,3);
    outtextxy(250,200,"Loading...");
    rectangle(90,140,510,180);
for(r=0;r<100;r++)
{
for(c=0;c<100;c++)
{
bar(100+c,150,400+c,170);              /*loading bar*/
delay(100);
}
break;
}
cleardevice();
settextstyle(7,0,4);
outtextxy(20,150,"We present you the game tic tac toe!");
delay(2100);
for (loop=0; loop<500; loop++)
{
setcolor(11);
settextstyle(3,0,1);
outtextxy(640-(loop+130),10,"IN THE NAME OF ALLAH, THE MOST GRACIOUS AND THE MOST MERCIFUL!");            /*text moving from right to left*/
settextstyle(7,0,3);
outtextxy(30,300+(loop-300),"Made by:Urooj Sohail & Taleaa Ghori");                                       /*text moving from top to bottom*/
cleardevice();
}
settextstyle(3,0,1);
outtextxy(640-(500+130),10,"IN THE NAME OF ALLAH, THE MOST GRACIOUS AND THE MOST MERCIFUL!");
settextstyle(7,0,3);
outtextxy(30,400,"Made by:Urooj Sohail & Taleaa Ghori");
se ttextstyle(7,0,4);
setcolor(4);
outtextxy(10,100,"Welcome! YOU(X) v/s COMPUTER(0)");
outtextxy(200,150,"Press Enter");
}


void screen(void)               /*game board*/
{
setbkcolor(9);
{
settextstyle(5,0,8);
outtextxy(70,300,"Tic Tac Toe");
}                                                                                                                                                                                                                                       setfillstyle(13,4);
bar(200,120,410,330);                   /*setting the background of the board*/
int row,col;
for(row=0;row<=200;row=row+70)
{
for(col=0;col<=200;col=col+70)
{
setcolor(0);
rectangle(200+col,120+row,270+col,190+row);        /*drawing the board of 9 boxes*/
}
}
input();                        /*taking input through function*/
}

void input()
{
int x,y;
printf("Enter X co-ordinate -- ");
scanf("%d",&x);
printf("Enter Y co-ordinate -- ");
scanf("%d",&y);
}
/*
for(int x=0;x<=2;x++)
{
for(int y=0;y<=2;y++)
{
if(game[x][y]=='X')
cross(x,y);
if(game[x][y]=='O')
circle(x,y);
}
}

if(game[x-1][y-1]=='*')
game[x-1][y-1]='X';
/*if(game[x-1][y-1]==game[0][0])          /*drawing circle
circle(235,155,20);
if(game[x-1][y-1]==game[0][1])
circle(305,155,20);
if(game[x-1][y-1]==game[0][2])             /*till 1st row
circle(375,155,20);

if(game[x-1][y-1]==game[1][0])
circle(235,225,20);
if(game[x-1][y-1]==game[1][1])
circle(305,225,20);
if(game[x-1][y-1]==game[1][2])
circle(375,225,20);                         /*till 2nd row

if(game[x-1][y-1]==game[2][0])
circle(235,295,20);
if(game[x-1][y-1]==game[2][1])
circle(305,295,20);
if(game[x-1][y-1]==game[2][2])             /*till 3rd row
circle(375,295,20);


if(game[x-1][y-1]==game[0][0])              /*drawing cross
line(215,135,255,175);
line(255,135,215,175);
if(game[x-1][y-1]==game[0][1])
line(285,135,325,175);
line(325,135,285,175);
if(game[x-1][y-1]==game[0][2])
line(355,135,395,175);                      /*till 1st row*
line(395,135,355,175);

if(game[x-1][y-1]==game[1][0])
line(215,205,255,245);
line(255,205,215,245);
if(game[x-1][y-1]==game[1][1])
line(285,205,325,245);
line(325,205,285,245);
if(game[x-1][y-1]==game[1][2])
line(355,205,395,245);                      /*till 2nd row*
line(395,205,355,245);

if(game[x-1][y-1]==game[2][0])
line(215,275,255,315);
line(255,275,215,315);
if(game[x-1][y-1]==game[2][1])
line(285,275,325,315);
line(325,275,285,315);
if(game[x-1][y-1]==game[2][2])               *till 3rd row*
line(355,275,395,315);
line(395,275,355,315);
}
*/

I am using #include "graphics.h" in c++.

I am using visual studio 2008 as my IDE.

The problem is I can't build my code.

Here is my code...

#include<stdio.h>
#include<conio.h>
#include "graphics.h"
#include<stdlib.h>
#include<dos.h>

char game[3][3];
void screen(void);
void introducing(void);
void input(void);
void circle(int,int);
void cross(int,int);

void main(void)
{
int gd=DETECT, gm, errorcode;   /* request auto detection */
char msg[80];
initgraph(&gd,&gm,"\\tc\\bgi"); /* initialize graphics */
errorcode = graphresult();      /* read result of initialization */
if(errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
cleardevice();
introducing();
getche();
cleardevice();
screen();
getche();
closegraph();
}


void introducing(void)                   /*introduction of the project*/
{
    setbkcolor(5);
    int loop;
    setcolor(1);
    int r,c;
    settextstyle(5,0,3);
    outtextxy(250,200,"Loading...");
    rectangle(90,140,510,180);
for(r=0;r<100;r++)
{
for(c=0;c<100;c++)
{
bar(100+c,150,400+c,170);              /*loading bar*/
delay(100);
}
break;
}
cleardevice();
settextstyle(7,0,4);
outtextxy(20,150,"We present you the game tic tac toe!");
delay(2100);
for (loop=0; loop<500; loop++)
{
setcolor(11);
settextstyle(3,0,1);
outtextxy(640-(loop+130),10,"IN THE NAME OF ALLAH, THE MOST GRACIOUS AND THE MOST MERCIFUL!");            /*text moving from right to left*/
settextstyle(7,0,3);
outtextxy(30,300+(loop-300),"Made by:Urooj Sohail & Taleaa Ghori");                                       /*text moving from top to bottom*/
cleardevice();
}
settextstyle(3,0,1);
outtextxy(640-(500+130),10,"IN THE NAME OF ALLAH, THE MOST GRACIOUS AND THE MOST MERCIFUL!");
settextstyle(7,0,3);
outtextxy(30,400,"Made by:Urooj Sohail & Taleaa Ghori");
se ttextstyle(7,0,4);
setcolor(4);
outtextxy(10,100,"Welcome! YOU(X) v/s COMPUTER(0)");
outtextxy(200,150,"Press Enter");
}


void screen(void)               /*game board*/
{
setbkcolor(9);
{
settextstyle(5,0,8);
outtextxy(70,300,"Tic Tac Toe");
}                                                                                                                                                                                                                                       setfillstyle(13,4);
bar(200,120,410,330);                   /*setting the background of the board*/
int row,col;
for(row=0;row<=200;row=row+70)
{
for(col=0;col<=200;col=col+70)
{
setcolor(0);
rectangle(200+col,120+row,270+col,190+row);        /*drawing the board of 9 boxes*/
}
}
input();                        /*taking input through function*/
}

void input()
{
int x,y;
printf("Enter X co-ordinate -- ");
scanf("%d",&x);
printf("Enter Y co-ordinate -- ");
scanf("%d",&y);
}
/*
for(int x=0;x<=2;x++)
{
for(int y=0;y<=2;y++)
{
if(game[x][y]=='X')
cross(x,y);
if(game[x][y]=='O')
circle(x,y);
}
}

if(game[x-1][y-1]=='*')
game[x-1][y-1]='X';
/*if(game[x-1][y-1]==game[0][0])          /*drawing circle
circle(235,155,20);
if(game[x-1][y-1]==game[0][1])
circle(305,155,20);
if(game[x-1][y-1]==game[0][2])             /*till 1st row
circle(375,155,20);

if(game[x-1][y-1]==game[1][0])
circle(235,225,20);
if(game[x-1][y-1]==game[1][1])
circle(305,225,20);
if(game[x-1][y-1]==game[1][2])
circle(375,225,20);                         /*till 2nd row

if(game[x-1][y-1]==game[2][0])
circle(235,295,20);
if(game[x-1][y-1]==game[2][1])
circle(305,295,20);
if(game[x-1][y-1]==game[2][2])             /*till 3rd row
circle(375,295,20);


if(game[x-1][y-1]==game[0][0])              /*drawing cross
line(215,135,255,175);
line(255,135,215,175);
if(game[x-1][y-1]==game[0][1])
line(285,135,325,175);
line(325,135,285,175);
if(game[x-1][y-1]==game[0][2])
line(355,135,395,175);                      /*till 1st row*
line(395,135,355,175);

if(game[x-1][y-1]==game[1][0])
line(215,205,255,245);
line(255,205,215,245);
if(game[x-1][y-1]==game[1][1])
line(285,205,325,245);
line(325,205,285,245);
if(game[x-1][y-1]==game[1][2])
line(355,205,395,245);                      /*till 2nd row*
line(395,205,355,245);

if(game[x-1][y-1]==game[2][0])
line(215,275,255,315);
line(255,275,215,315);
if(game[x-1][y-1]==game[2][1])
line(285,275,325,315);
line(325,275,285,315);
if(game[x-1][y-1]==game[2][2])               *till 3rd row*
line(355,275,395,315);
line(395,275,355,315);
}
*/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦萦几度 2024-11-13 19:02:06

这些函数和头文件是旧的 Borland 图形扩展的一部分,而不是标准 C 库或 Visual Studio 的一部分。

Those functions and header are part of the old Borland graphics extensions and are not part of the standard C library or Visual Studio.

怎樣才叫好 2024-11-13 19:02:06

使用#include "graphics.h",您可以将库的头文件包含到代码中。头文件必须位于 Visual Studio 的包含路径中。您可以在 VS 2008 中的项目属性中设置其他包含路径。

为此:右键单击项目资源管理器中的项目
->属性
->其他包含目录

with #include "graphics.h" you include a header file of a library into your code. The header file must be in the include paths of visual studio. You can set additional include paths in the project propert within VS 2008.

To do so: right click on Project in the project explorer
->Properties
->Additional Include directories

梦中楼上月下 2024-11-13 19:02:06

您是否偶然尝试将 Borland 图形接口的功能用于 16 位 DOS 应用程序?

http://www.cprogrammingexpert.com/C/Tutorial/graphics.aspx

Are you by chance trying to use the features from the Borland Graphics Interface for 16-bit DOS applications?

http://www.cprogrammingexpert.com/C/Tutorial/graphics.aspx

酸甜透明夹心 2024-11-13 19:02:06

请参阅此资源:
http://www.cs.colorado.edu/~main/bgi/visual< /a>

有用于 Visual Studio 2005/2008/2010 的 WinBGIM 图形库的项目

See on this resurce:
http://www.cs.colorado.edu/~main/bgi/visual

There are projects with WinBGIm Graphics Library for visual studio 2005/2008/2010

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文