Text and background Color

This is a discussion on Text and background Color within the A Brief History of Cprogramming.com forums, part of the Community Boards category; When ever I try to make my text or the background another color other then the normal DOS color (gray, ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    43

    Unhappy Text and background Color

    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.
    Code:
    #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.
    ()()() MonKey ware
    Kyle J. R.

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    26
    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.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    43
    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.
    ()()() MonKey ware
    Kyle J. R.

  4. #4
    Unregistered
    Guest
    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");

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    43

    Cool

    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");
    ()()() MonKey ware
    Kyle J. R.

  6. #6
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Render text
    By Livijn in forum C++ Programming
    Replies: 6
    Last Post: 07-06-2007, 03:32 PM
  2. Changing static control text color
    By maxorator in forum Windows Programming
    Replies: 6
    Last Post: 11-03-2005, 09:03 AM
  3. MFC: Change the color of static text with button press?
    By BrianK in forum Windows Programming
    Replies: 2
    Last Post: 06-16-2004, 11:03 PM
  4. ANSI Text Color?
    By Kavity in forum Game Programming
    Replies: 0
    Last Post: 10-18-2002, 03:03 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 09:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21