如何制作简单的DOS程序(不滚动) [英] How to make simple DOS program (without scrolling)

查看:162
本文介绍了如何制作简单的DOS程序(不滚动)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习C ++,已经有两个月了。



在学习了语言的许多方面之后,我想练习制作简单的程序而不用图形UI。



我想制作像MadLibs或MasterMind这样的简单游戏。



我该如何去做这样做而不滚动。

我读过他们以前使用数组做过的地方,但是当我尝试时,这并没有消除滚动。



怎么做?



[更新]

找到它。

I'm learning C++, It has been two months now.

After learning many aspect of the language, I want to practice to make simple program without Graphic UI.

I want to make simple games like MadLibs or MasterMind.

How do I go about doing that without scrolling.
I've read somewhere that they used to do it using arrays, but when I try, that didn't eliminate the scrolling.

How to do it?

[update]
found it.

#include<windows.h>
main()
{
    some code....;
    system("cls");
    some more code;
}





=================



[更新]

我在尝试看起来像这样,在互联网上找到了这个madlib。





=================

[update]
What I was trying kinda look like this, found this madlib on the internet.

#include<iostream>
#include <string>
using namespace std;

int main()
{

	cout << "Welcome\n" << "Enter your name" << endl;
	string userName;
	getline(cin, userName);
	system("cls");

	cout << "Hi, " << userName << endl;
	cout << "Enter an adjective: ";
	string adjective1;
	getline(cin, adjective1);

	cout << "Enter a noun: ";
	string noun1;
	getline(cin, noun1);

	cout << "Spell a number: ";
	string number;
	getline(cin,number);

	cout << "Enter a noun: ";
	string noun2;
	getline(cin, noun2);

	cout << "Enter an adjective: ";
	string adjective2;
	getline(cin, adjective2);

	cout << "Enter an verb: ";
	string verb;
	getline(cin, verb);

	cout << "Enter a noun: ";
	string noun3;
	getline(cin, noun3);

	cout << "Enter a body part: ";
	string bodyPart;
	getline(cin, bodyPart);

	cout << "Enter an adjective: ";
	string adjective3;
	getline(cin, adjective3);
	system("cls");

	cout << "Look, I guarantee there`ll be " << adjective1
		<< " times. I guarantee that at some " << noun1
		<< ", \n" << number << " or both of us is gonna want to get out of this "
		<< noun2 << ". \nBut I also guarantee that if I don`t ask you to be "
		<< adjective2 << ", \nI`ll " << verb << " it for the rest of my "
		<< noun3 << ", because I know, \nin my " << bodyPart << ", you`re the "
		<< adjective3 << " one for me." << endl << endl;

	cout << "Thank you!" << endl;
	getchar();
	return 0;
}





- >将来我打算学习如何制作简单的菜单/框架(有点像来自旧Windows的命令提示符中的'编辑'软件)。



- >我还计划让用户'随机'语言部分这将从小字典文件中生成一个单词。



-->In future I'm planning to learn how to make simple menu/frame based from this (kinda like the 'Edit' software in command prompt from old Windows).

-->I also plans to let the user to 'random' the language parts which will generate a word from small dictionary file.

推荐答案

您可能想要查看文本用户界面库,例如curses [ ^ ]。它们允许比系统(cls)更多的控制。



PS:尽管主要用于UNIX像系统一样,有Windows实现。我们这里仍然有一个基于curses的应用程序,可在现代Windows系统上运行。
You might want to check out text user interface libraries such as curses[^]. They allow much more control than system("cls").

P.S.: Even though mainly used in UNIX like systems, there are Windows implementations. We still have a curses-based app here that runs on modern Windows systems.


有关信息:DOS允许GUI。

你在做什么是 console 应用程序,或者说 char模式应用程序。

通过使用解决方案2中的库,您将能够控制光标的位置和屏幕上显示的内容颜色。



您之前所做的事情被称为 Teletype 应用程序,因为换行是你对屏幕上事物的唯一控制。
For information: DOS permit GUI.
What you are doing is a console application, or said otherwise char mode application.
By using a library like in Solution 2, you will be able to control the position of cursor and color of what goes on screen.

What you have been doing until now is called Teletype application because Linefeed is your only control on how thing are on screen.


请参阅: http://stackoverflow.com/questions/1670891/how-can-i-print-a-string-to-the-console -at-specific-coordinates-in-c [ ^ ]。



Windows上没有DOS程序这样的东西。这不仅仅是错误的话语;很明显,你使用的操作系统的基本知识已经过时了。



-SA


这篇关于如何制作简单的DOS程序(不滚动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆