1

I'm using turbo c++ which launches DOSBox 0.74

I have the following program:

#include <conio.h>
#include <stdlib.h>

int main() {
  clrscr();
  window(100, 100, 200, 200);
  textcolor(3);
  textbackground(6);

  cprintf("Hello world");

  getch();

  return 0;
} 

It works and it's pretty same copy from 2 sites, except, it dont make the window. window (100, 100, 200, 200) should make a window with coordinates (100, 100) and (200, 200) from top left corner, but it doesn't happen and text just printed at most top left corner. I didn't find anyone with same problem. Instead tutorial sites shows this example and even screenshots as working.

Did anyone met this problem?

4

1 回答 1

1

window()函数 from仅在文本屏幕conio.h上定义一个活动窗口。默认屏幕为 80x25 文本屏幕。您指定的坐标在屏幕外,因此没有创建任何窗口。 尝试这个:window(100, 100, 200, 200);

window(10, 7, 50, 19);
gotoxy(16, 7);
cputs("Hello World");

对于图形 HelloWorld 程序,您需要包含graphics.h并设置图形视频模式,使用detectgraph(), initgraph(), ...

于 2021-12-01T20:12:20.207 回答