求助高手,c语言,编译错误
#include<stdio.h>#include<bios.h>intx=10,y=10;inti,j;intn0=0,n=0;intmap[15][15]={1,1,...
#include <stdio.h>
#include <bios.h>
int x=10, y=10;
int i,j;
int n0=0,n=0;
int map[15][15]={
1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,};
void draw(int x,int y)
{
clrscr();
for(i=0;i<15;i++)
for(j=0;j<15;j++)
{
if(map[i][j]==1){gotoxy(j+1, i+1);printf("%c",3);}
}
gotoxy(x, y);
printf("%c",2);
}
void tell()
{
if(map[y-1][x-1]==1){map[y-1][x-1]=0 ;n++;}
if(n>=n0){ clrscr();printf("win!!");getch();}
void main()
{
for(i=0;i<15;i++)
for(j=0;j<15;j++)
if(map[j][i]==1)n0=n0+1;
draw(x,y);
while("")
{
tell();
switch(bioskey(0))
{
case 18432:
y-=1;draw(x,y);break;
case 20480:
y+=1; draw(x,y);break;
case 19200:
x-=1; draw(x,y);break;
case 19712:
x+=1; draw(x,y);break;
}
}
}
新手,分少。网上看教程写的代码,总是编译错误
C:\Users\lenovo\Desktop\game.c(24) : warning C4013: 'clrscr' undefined; assuming extern returning int
C:\Users\lenovo\Desktop\game.c(28) : warning C4013: 'gotoxy' undefined; assuming extern returning int
C:\Users\lenovo\Desktop\game.c(36) : warning C4013: 'getch' undefined; assuming extern returning int
C:\Users\lenovo\Desktop\game.c(37) : error C2143: syntax error : missing ';' before 'type'
C:\Users\lenovo\Desktop\game.c(39) : warning C4552: '<' : operator has no effect; expected operator with side-effect
C:\Users\lenovo\Desktop\game.c(39) : error C2143: syntax error : missing ';' before ')'
C:\Users\lenovo\Desktop\game.c(40) : warning C4552: '<' : operator has no effect; expected operator with side-effect
C:\Users\lenovo\Desktop\game.c(40) : error C2143: syntax error : missing ';' before ')'
执行 cl.exe 时出错. 展开
#include <bios.h>
int x=10, y=10;
int i,j;
int n0=0,n=0;
int map[15][15]={
1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,};
void draw(int x,int y)
{
clrscr();
for(i=0;i<15;i++)
for(j=0;j<15;j++)
{
if(map[i][j]==1){gotoxy(j+1, i+1);printf("%c",3);}
}
gotoxy(x, y);
printf("%c",2);
}
void tell()
{
if(map[y-1][x-1]==1){map[y-1][x-1]=0 ;n++;}
if(n>=n0){ clrscr();printf("win!!");getch();}
void main()
{
for(i=0;i<15;i++)
for(j=0;j<15;j++)
if(map[j][i]==1)n0=n0+1;
draw(x,y);
while("")
{
tell();
switch(bioskey(0))
{
case 18432:
y-=1;draw(x,y);break;
case 20480:
y+=1; draw(x,y);break;
case 19200:
x-=1; draw(x,y);break;
case 19712:
x+=1; draw(x,y);break;
}
}
}
新手,分少。网上看教程写的代码,总是编译错误
C:\Users\lenovo\Desktop\game.c(24) : warning C4013: 'clrscr' undefined; assuming extern returning int
C:\Users\lenovo\Desktop\game.c(28) : warning C4013: 'gotoxy' undefined; assuming extern returning int
C:\Users\lenovo\Desktop\game.c(36) : warning C4013: 'getch' undefined; assuming extern returning int
C:\Users\lenovo\Desktop\game.c(37) : error C2143: syntax error : missing ';' before 'type'
C:\Users\lenovo\Desktop\game.c(39) : warning C4552: '<' : operator has no effect; expected operator with side-effect
C:\Users\lenovo\Desktop\game.c(39) : error C2143: syntax error : missing ';' before ')'
C:\Users\lenovo\Desktop\game.c(40) : warning C4552: '<' : operator has no effect; expected operator with side-effect
C:\Users\lenovo\Desktop\game.c(40) : error C2143: syntax error : missing ';' before ')'
执行 cl.exe 时出错. 展开
4个回答
展开全部
/*编译完全通过,但是bioskey(0)需要TC支持,我是vc,所以无法运行。这个是那个什么老鼠迷宫的么?*/
#include <stdio.h>
//#include "bios.h"
#include <windows.h>
#include <conio.h> /*getch()*/
/*在项目中添加bios.h,内容如下。或者用下面代码替换#include "bios.h"*/
/* bios.h
Access to bios services.
Copyright (c) Borland International 1987,1988
All Rights Reserved.
*/
#if __STDC__
#define _Cdecl
#else
#define _Cdecl cdecl
#endif
int _Cdecl bioscom(int cmd, char abyte, int port);
int _Cdecl biosdisk(int cmd, int drive, int head, int track, int sector,
int nsects, void *buffer);
int _Cdecl biosequip(void);
int _Cdecl bioskey(int cmd);
int _Cdecl biosmemory(void);
int _Cdecl biosprint(int cmd, int abyte, int port);
long _Cdecl biostime(int cmd, long newtime);
/*********************************end of "bios.h"**********************************/
int x=10, y=10;
int i,j;
int n0=0,n=0;
int map[15][15]={
1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,};
/*********************************************************************/
void clrscr(void)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
HANDLE hConsoleOut;
COORD Home = {0,0};
DWORD dummy;
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
FillConsoleOutputCharacter(hConsoleOut,' ',csbiInfo.dwSize.X * csbiInfo.dwSize.Y,Home,&dummy);
csbiInfo.dwCursorPosition.X = 0;
csbiInfo.dwCursorPosition.Y = 0;
SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);
}
void gotoxy(int x,int y)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
HANDLE hConsoleOut;
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
csbiInfo.dwCursorPosition.X = x;
csbiInfo.dwCursorPosition.Y = y;
SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);
}
/*********************************************************************/
void draw(int x,int y)
{
clrscr();
for(i=0;i<15;i++)
for(j=0;j<15;j++)
{
if(map[i][j]==1){gotoxy(j+1, i+1);printf("%c",3);}
}
gotoxy(x, y);
printf("%c",2);
}
void tell()
{
if(map[y-1][x-1]==1)
{
map[y-1][x-1]=0;
n++;
}
if(n>=n0)
{
clrscr();
printf("win!!");
getch();
}
}
void main()
{
for(i=0;i<15;i++)
for(j=0;j<15;j++)
if(map[j][i]==1)
n0=n0+1;
draw(x,y);
while("")
{
tell();
switch(bioskey(0))
{
case 18432:
y-=1;
draw(x,y);
break;
case 20480:
y+=1;
draw(x,y);
break;
case 19200:
x-=1;
draw(x,y);
break;
case 19712:
x+=1;
draw(x,y);
break;
}
}
}
#include <stdio.h>
//#include "bios.h"
#include <windows.h>
#include <conio.h> /*getch()*/
/*在项目中添加bios.h,内容如下。或者用下面代码替换#include "bios.h"*/
/* bios.h
Access to bios services.
Copyright (c) Borland International 1987,1988
All Rights Reserved.
*/
#if __STDC__
#define _Cdecl
#else
#define _Cdecl cdecl
#endif
int _Cdecl bioscom(int cmd, char abyte, int port);
int _Cdecl biosdisk(int cmd, int drive, int head, int track, int sector,
int nsects, void *buffer);
int _Cdecl biosequip(void);
int _Cdecl bioskey(int cmd);
int _Cdecl biosmemory(void);
int _Cdecl biosprint(int cmd, int abyte, int port);
long _Cdecl biostime(int cmd, long newtime);
/*********************************end of "bios.h"**********************************/
int x=10, y=10;
int i,j;
int n0=0,n=0;
int map[15][15]={
1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,};
/*********************************************************************/
void clrscr(void)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
HANDLE hConsoleOut;
COORD Home = {0,0};
DWORD dummy;
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
FillConsoleOutputCharacter(hConsoleOut,' ',csbiInfo.dwSize.X * csbiInfo.dwSize.Y,Home,&dummy);
csbiInfo.dwCursorPosition.X = 0;
csbiInfo.dwCursorPosition.Y = 0;
SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);
}
void gotoxy(int x,int y)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
HANDLE hConsoleOut;
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
csbiInfo.dwCursorPosition.X = x;
csbiInfo.dwCursorPosition.Y = y;
SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);
}
/*********************************************************************/
void draw(int x,int y)
{
clrscr();
for(i=0;i<15;i++)
for(j=0;j<15;j++)
{
if(map[i][j]==1){gotoxy(j+1, i+1);printf("%c",3);}
}
gotoxy(x, y);
printf("%c",2);
}
void tell()
{
if(map[y-1][x-1]==1)
{
map[y-1][x-1]=0;
n++;
}
if(n>=n0)
{
clrscr();
printf("win!!");
getch();
}
}
void main()
{
for(i=0;i<15;i++)
for(j=0;j<15;j++)
if(map[j][i]==1)
n0=n0+1;
draw(x,y);
while("")
{
tell();
switch(bioskey(0))
{
case 18432:
y-=1;
draw(x,y);
break;
case 20480:
y+=1;
draw(x,y);
break;
case 19200:
x-=1;
draw(x,y);
break;
case 19712:
x+=1;
draw(x,y);
break;
}
}
}
追问
非常感谢,但是执行的时候还是有一个问题
***.obj : error LNK2001: unresolved external symbol _bioskey
Debug/***.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
还望高手指教啊
追答
/*编译完全通过,但是bioskey(0)需要TC支持,我是vc,所以无法运行。这个是那个什么老鼠迷宫的么?*/
恩,就是我开始说的那么问题,你需要用tc才能运行。报错的error就是没有bioskey(0)的定义,与你编译环境有关
展开全部
应该是中间一些大括号什么的少写了,看看下面这样行不行
#include <stdio.h>
#include <bios.h>
int x=10, y=10;
int i,j;
int n0=0,n=0;
int map[15][15]={
1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1
};
void draw(int x,int y)
{
clrscr();
for(i=0;i<15;i++)
for(j=0;j<15;j++)
{
if(map[i][j]==1){gotoxy(j+1, i+1);printf("%c",3);}
}
gotoxy(x, y);
printf("%c",2);
}
void tell()
{
if(map[y-1][x-1]==1){map[y-1][x-1]=0 ;n++;}
if(n>=n0){
clrscr();
printf("win!!");
getch();
}
}
void main()
{
for(i=0;i<15;i++)
for(j=0;j<15;j++)
if(map[j][i]==1)n0=n0+1;
draw(x,y);
while("")
{
tell();
switch(bioskey(0))
{
case 18432:
y-=1;draw(x,y);break;
case 20480:
y+=1; draw(x,y);break;
case 19200:
x-=1; draw(x,y);break;
case 19712:
x+=1; draw(x,y);break;
}
}
}
#include <stdio.h>
#include <bios.h>
int x=10, y=10;
int i,j;
int n0=0,n=0;
int map[15][15]={
1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1
};
void draw(int x,int y)
{
clrscr();
for(i=0;i<15;i++)
for(j=0;j<15;j++)
{
if(map[i][j]==1){gotoxy(j+1, i+1);printf("%c",3);}
}
gotoxy(x, y);
printf("%c",2);
}
void tell()
{
if(map[y-1][x-1]==1){map[y-1][x-1]=0 ;n++;}
if(n>=n0){
clrscr();
printf("win!!");
getch();
}
}
void main()
{
for(i=0;i<15;i++)
for(j=0;j<15;j++)
if(map[j][i]==1)n0=n0+1;
draw(x,y);
while("")
{
tell();
switch(bioskey(0))
{
case 18432:
y-=1;draw(x,y);break;
case 20480:
y+=1; draw(x,y);break;
case 19200:
x-=1; draw(x,y);break;
case 19712:
x+=1; draw(x,y);break;
}
}
}
追问
非常感谢,但虽然编译通过了,但执行的时候还是有一个错误,看了半天,很痛苦。非常感谢你这么快的回答。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不要我们帮你找出错误,要学会自己看错误提示,问题都不大,不是丢了分号就是多了逗号,写程序时一定要仔细一点,否则等回头再去找错误就会麻烦了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询