Like Tree1Likes
  • 1 Post By Salem

changing the color of some partcular line or part in console program

This is a discussion on changing the color of some partcular line or part in console program within the C++ Programming forums, part of the General Programming Boards category; Hi If I include the call function system("color 1a") changes the console's background color and text color. But I was ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    254

    changing the color of some partcular line or part in console program

    Hi

    If I include the call function system("color 1a") changes the console's background color and text color. But I was the bold part to appear in different color, let's say, green? How do I change the color of some particular line or part in the program? I'm using Windows XP so you can tell me something Windows specific; it will do the job. Thanks your help and time. And please don't forget I'm a newbie to programming.

    Code:
    // program to calculate area of a circle
    
    #include <iostream>
    #include <cmath>
    #include <cstdlib>
    #include <windows.h>
    #include <stdlib.h>
    
    using namespace std;
    
    int main()
    
    {
        system("color 1a")
        float R, A, C;
        cout << "Enter the radius R = ";
        cin >> R;
        A = 3.142*R*R;
        C = 2*3.142*R;
        if (R >= 0)
           {
           
           cout << "Area = " << A << endl;
           cout << "Circumference = " << C << endl;
           
           }
        else
            cout << "Invalid R" << endl;
        system ("PAUSE");
    }
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    Win32 Console Applications 1
    Work your way through until you get to the colours.
    ekosix likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    254
    Thanks, Salem. It's a good link. I'm reading. I'm sure I would have some questions to you so be there to help me, please!

    Best wishes
    Jackson
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  4. #4
    INSANE INSIDE ekosix's Avatar
    Join Date
    May 2010
    Location
    Rio de Janeiro, Brazil
    Posts
    44
    OR, you can try NCURSES library: ncurses - Wikipedia, the free encyclopedia

    As you use Windows, you will need PDCURSES: PDCurses for Windows
    I like it very much, and if you want to know why, take a look at some apps using Ncurses: PDCurses for Windows

    If you need help with it, read its documentation: http://www.ibiblio.org/pub/Linux/doc...ming-HOWTO.pdf

    For your task, the code would be very simple too...
    Enjoy!
    liked this /\
    so like it there >

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing color of pen
    By Gordon in forum Windows Programming
    Replies: 4
    Last Post: 04-13-2007, 10:26 AM
  2. Replies: 2
    Last Post: 11-18-2006, 02:31 AM
  3. Color changing
    By FingerPrint in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 11:07 PM
  4. Changing the colors in a command line program?
    By Scott B. in forum C++ Programming
    Replies: 1
    Last Post: 08-16-2005, 10:15 PM
  5. color changing in c++
    By cppdungeon in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2005, 06:20 PM

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