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?


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

int main(void)

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

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

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

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


return 0;

Thanks to those who help.

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.

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)

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.

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

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


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.