问题
Why I see nothing when I run my code ? I use DOSBox.
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <bios.h>
#include <ctype.h>
#include <math.h>
int main() {
int gdriver = DETECT,gmode = 0;
initgraph(&gdriver,&gmode,"C:\\TC\\BGI");
struct time t;
moveto(5,10);
outtext("Hello");
moveto(6,11);
outtext("World**strong text**");
moveto(1,24);
outtext("Press: 1-About_Author, 2-Current_Time,ESC to EXIT");
closegraph();
return 0;
}
回答1:
Your code is right. The problem is with the path you are giving to search for the display driver files "C:\\TC\\BGI"
. This generally happen because the tc
is not root of the mounted drive or the .exe
file path you are using is not c:\\TC
. Replace the path with "..//bgi"
. This will redirect from bin
(the current working directory) to bgi.
来源:https://stackoverflow.com/questions/34219457/graphical-functions-in-c