Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two things...

Status
Not open for further replies.

A1METALHEAD

Programmer
May 21, 2004
76
US
hi. i have been trying to find a way to change the text color, and the background color of spacific text. i have found the following example:

#include "conio.h"

int main(int argc, void** argv)
{
textcolor(LIGHTGREEN);
cout << "Hello World!!!" << endl;
textcolor(LIGHTRED);
cout << "ERROR!!!" << endl;

textcolor(BLACK);
textbackground(LIGHTRED);
cout << "Error message here!" << endl;

getch();

return 0;
}

but it dosent work! same with pausing for a certn amount of time using the Sleep() funciton. i get "textcolor() is undefined, first use this function" and so on saying that all the functions are undefined (im using dev c++). is there any way that you could change the background+color of text or pause? thanks

~metalhead
 
> #include "conio.h"
If I recall correctly, the hacky way is to
#include "conio.c".

More correctly, you include some additional library in the project settings page for the project you are compiling.

Of course, strictly speaking you should not be using conio.h at all in a win32 environment.
You can get better control over a console environment by using this
win32 console

> int main(int argc, void** argv)
Nope, its a char** for the 2nd parameter

> textcolor(LIGHTGREEN);
The only routine which guarantees coloured output is [tt]cprintf()[/tt], which is similar to the regular C printf() function.
Using standard cout is not guaranteed to be affected by attempts to change the colour.

--
 
im sorry but i may sound a bit daft but how do you use it to change the background and color of certen text?
 
the functions you referenced were from Borland's old DOS C and C++ compilers I do believe. In windows, there are functions to manipulate the console window's text and attributes, MSDN should have more information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top