PDA

View Full Version : Text and background Color



Goof Program
03-20-2002, 12:20 PM
When ever I try to make my text or the background another color other then the normal DOS color (gray, black) it all ways puts my text and stuff weird. why does it do that and how can I fix it?

Sample.


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

int main(void)
{

printf(" This is a text color test.\n");

textcolor(BLUE);
cprintf(" This should be the color: BLUE.");

printf(" This should be right below the BLUE text.");

textcolor(LIGHTGRAY);
textbackground(BLUE);
cprintf(" This should have a BLUE background.");

getchar();

return 0;
}


Thanks to those who help.

ghe1
03-20-2002, 03:19 PM
If you are just looking to change the background and font color of the cmd window, I suggest opening up the cmd window and then right clicking on the menu bar. You should be able to select PROPERTIES. Click on the Colors Tab and you can change the colors freely.

Goof Program
03-20-2002, 04:24 PM
No thats not what I wanted to do, What I want is to know is when I use the textcolor(); and taxtbackground(); to change the colors, and then use cprintf(""); to display what ever, how come it does not act just like the printf(); function? compile my code and you will see what I mean.

Unregistered
03-25-2002, 10:49 PM
do you mean C won't place your text on a new line?
Use the escape sequences: \n (newline)

EG.
printf("1st line");
printf("\n2nd Line");

Goof Program
03-26-2002, 06:00 AM
It's ok, some one replyed to my other post and said i need to use a carrage return [\r] not just [\n] new line.

textcolor(13);
cprintf("Text here\r\n");

sean
03-29-2002, 06:59 PM
You could also try putting the assembler code like this

asm
{
...
}

As far as I know, most compilers will accept this, and because this is about as close as you can get to making the microchip itself while still speaking English, you can do just about anything - everything came from assembler if you think about it.