简体   繁体   English

编译 C 文件时出错。 致命错误:找不到“conio.h”文件

[英]An error while compiling a C file. fatal error: 'conio.h' file not found

I am using macOS.我正在使用 macOS。

this is a part of a code.这是代码的一部分。

#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <time.h>

void firstPage();  
void instructions();       
void border();       
void patternOfGrass();
void patternOfPipes();
void birdFlies(int);
void birdFliesCont();
int  getkey();
int  gameOver();
void gotoxy(int, int);
void continueGame();
void youLose();


int length_of_pipes[80],speed=700,score=0,flag=0,level=1;

these are errors I get.这些是我得到的错误。

flappy.c:2:10: fatal error: 'conio.h' file not found
#include <conio.h>
         ^~~~~~~~~
1 error generated.
kam~ gcc flappy.c
flappy.c:3:10: fatal error: 'graphics.h' file not found
#include <graphics.h>

also it displays errors in dos.h and time.h too.它还在 dos.h 和 time.h 中显示错误。

Your errors indicate that your code is meant for DOS (maybe Windows)您的错误表明您的代码适用于 DOS(可能是 Windows)

You might try: https://stackoverflow.com/a/4371596/3937你可以试试: https://stackoverflow.com/a/4371596/3937

  • dos.h is, as the name hints, the MS DOS API provided by Borland for their Turbo C and Turbo C++ compilers.顾名思义, dos.h是 Borland 为其 Turbo C 和 Turbo C++ 编译器提供的 MS DOS API。 It contains everything you need for MS DOS programming.它包含 MS DOS 编程所需的一切。

    You need to compile with Turbo C on a MS DOS compatible computer for that code to run.您需要在与 MS DOS 兼容的计算机上使用 Turbo C 编译该代码才能运行。 Some Windows version like Win 95/98 still had MS DOS emulation.一些 Windows 版本如 Win 95/98 仍然具有 MS DOS 仿真。

  • conio.h is a console user interface API, supported at some extent by several other MS DOS compilers. conio.h是一个控制台用户界面 API,在某种程度上受到其他几个 MS DOS 编译器的支持。

  • graphics.h is Borland's fancy EGA graphics library "Borland Graphics Interface". graphics.h是 Borland 的花哨的 EGA 图形库“Borland 图形界面”。 You need a fancy EGA graphics card to run it.你需要一个花哨的EGA 显卡来运行它。 And of course, a MS DOS computer with Borland Turbo C.当然,还有一台带有 Borland Turbo C 的 MS DOS 计算机。 A monitor that supports 16 colors is recommended.建议使用支持 16 colors 的显示器。

So first you have to download Turbo C from The Borland Museum - Antique Software: Turbo C version 2.01 .所以首先你必须从Borland 博物馆下载 Turbo C - Antique Software: Turbo C 2.01 版

After doing so, you need to contact technical museums and ask around if anyone have preserved an ancient computer that you could borrow.这样做之后,您需要联系技术博物馆并询问是否有人保存了您可以借用的古代计算机。 Or alternatively, you could spend weeks trying to get some "DOSBox" emulator working on your Mac.或者,您可以花费数周时间尝试让一些“DOSBox”模拟器在您的 Mac 上运行。 You might have to run the DOS emulator in a Windows emulator, I would assume.我假设您可能必须在 Windows 模拟器中运行 DOS 模拟器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM