My compiler is Turbo C++ v3.0 with DOS v5.0 emulated in DOSBox v0.74
I use this because Turbo C++ is the compiler with which
my highschool has chosen to teach the C++ programming language.
It has been stressed that I use this compiler while coding my final term project.
I'm running Windows 8.1 (64 bit) with Intel Core i5-3317U CPU @ 1.70GHz
For the sake of liveliness and in tribute to popular culture, I want my output screens to have green text.
The following is what seemed to work :
#include<iostream.h>
#include<conio.h>
void main(){
clrscr();
textcolor(2); // text set to green colour (conio.h function)
cprintf("\n\t Hello World"); // cprintf from conio.h
cout << "\n\t Hello World"; // cout from iostream.h
getch();
}
The output of which is as follows (screen has been trimmed to save space on this post):
According to the Help Section in Turbo C++,
cprintf()
sends formatted output to the text window on the screen.
As you can see, the text printed onto the screen by cout
is not green and my project is composed of a lot of cin
and cout
and some writing and reading files.
The result I desire can (although I have not yet tried) most likely be obtained by replacing all my cout << "...";
with cprintf("...");
but I've written so many cout statements that it's going to be hard to edit the code that much.
cprintf
is new territory for me and I'm slightly set aback by how
cprintf("\t");
is outputed as o
So, I'm not to keen using this. I don't wish to use this until and unless it is my only option.
The libraries cstdlib.h
and windows.h
are unavailable in Turbo C++ and hence I can't use their utilities to get what I want either.
In the end, all I want is that output prompt to display the text I've cout
ed in bright green. Minimal change to my code would be nice.
I wouldn't even mind having to change some settings of my emulator or compiler or shell to do it.
All help is much appreciated. Thank you in advance =)
Ah, the 1990s called, they want their QEMM back :)
The one solution I can think of is to put this in your CONFIG.SYS:
DEVICE=C:\DOS\ANSI.SYS
and then output ANSI escape sequences.