PDA

View Full Version : Colorful printf...



Trai_K
04-26-2002, 12:47 PM
So I have this function "void textcolor(int color)" where "color" can be replaced with the basic 16 colors upon input.


void highvideo();
void textcolor(int color);

I don't understand how to impliment this with "printf" though. Is there a text string output function that allows &color INSIDE of the string? Example:


// Where &R is the color red and &B is blue
printf("This &Rwould &Bbe &Rcolorful...");


Any ideas on how I can impliment this into a string output function?

Magos
04-26-2002, 02:06 PM
use cprintf() to print with colours, I think that the syntax is the same as in printf().


#include <stdio.h>
#include <conio.h>

int main()
{
textcolor(BLUE);
textbackground(RED);
cprintf("Hello world!");
getch();
}

Trai_K
04-26-2002, 05:55 PM
Would you be willing to post iostream.h for me?

I'm using LCC-WIN32 ver. 3.3 but it seems mine is bad.

I get a redefinition error for "_op_piostream_int" when I try to include the header in my code. I didn't redefine it in my code either, it simply comes up as being defined twice in the header.

So if you know you have a working version for my compiler, I'd appreciate you post it here.

Magos
04-27-2002, 09:25 AM
You don't need iostream.h for cprintf(), just stdio.h
And even if I send you iostream.h you only have the header, not the libraries.

Trai_K
04-27-2002, 07:15 PM
I need iostream.h for CIN and COUT (not so much COUT as CIN though.)

However, if you tell me a different function that does the similar as CIN, then that'd be cool as well.

I wanted the header file because that's where the error is coming from. The library files may not be the problem.

Now I ask kindly: Please post iostream.h, if you don't want to, then you have no obligation to post an excuse on this thread. Thank you.

Magos
04-28-2002, 09:40 AM
If you want the C-equivalent to cin, use scanf();
printf() and scanf() is C
cout & cin is C++

Anyway, here's the file: