get problem on text color

This is a discussion on get problem on text color within the C Programming forums, part of the General Programming Boards category; should be include the specific name of libary (eg: stdlib.h) to coding the text color ???...

  1. #1
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291

    get problem on text color

    should be include the specific name of libary (eg: stdlib.h) to coding the text color ???

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: get problem on text color

    Originally posted by beely
    should be include the specific name of libary (eg: stdlib.h) to coding the text color ???
    What? Please rephrase your jumble of words in the form of an actual question.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    adding "include <stdio.h>" only on the text color coding???

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by vVv
    Yes. (I don't get it)
    Neither can I. I suspect they're asking what header to include for things like "textcolor( )". (Borland compilers.)

    Check your compiler reference, or you could always try searching.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    yes, my friends, the meaning is like that. sorry for poor grammars then ...

  6. #6
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    Originally posted by quzah
    Neither can I. I suspect they're asking what header to include for things like "textcolor( )". (Borland compilers.)

    Check your compiler reference, or you could always try searching.

    Quzah.
    oh then, could ms vc++ compile it ??

  7. #7
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    Originally posted by vVv
    I think it's #include <conio.h> on Borland and MS compilers, #include <conio.c> if you happen to be using MingW/DevC++. Next time do as quzah suggested and consult google.
    oh, i have tried already, can't find the example of text color coding. from the previous thread, shown that the source code of changing the textcolor. but it can't working.

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    MSVC++ doesn't have a way to change console text color, if I recall correctly. You might want to check the MSDN for more information, or your compilers help files.

    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    thanks for help.

  10. #10
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    here is some simple code for textcolor in console mode:
    Code:
    #include <iostream.h> 
    #include <windows.h> 
    #include <conio.h> 
    
    #define co1  1 
    #define co2  2 
    #define co3  3 
    #define co4  4 
    #define co5  5 
    #define co6  6 
    #define co7  7 
    #define co8  8 
    #define co9  9 
    #define co10 10 
    #define co11 11 
    #define co12 12 
    #define co13 13 
    #define co14 14 
    #define co15 15 
    #define co16 16 
    #define co17 17 
    #define co18 18 
    #define co19 19 
    #define co20 20 
    
    void textcolor(WORD color) 
    { 
        SetConsoleTextAttribute(::GetStdHandle(STD_OUTPUT_HANDLE), color); 
    } 
    
    int main() 
    { 
       textcolor(co1); 
       cout << "co1" << endl; 
    
       textcolor(co2); 
       cout << "co2" << endl; 
    
       textcolor(co3); 
       cout << "co3" << endl; 
    
       textcolor(co4); 
       cout << "co4" << endl; 
    
       textcolor(co5); 
       cout << "co5" << endl; 
    
       textcolor(co6); 
       cout << "co6" << endl; 
    
       textcolor(co7); 
       cout << "co7" << endl; 
    
       textcolor(co8); 
       cout << "co8" << endl; 
    
       textcolor(co9); 
       cout << "co9" << endl; 
    
       textcolor(co10); 
       cout << "co10" << endl; 
    
       textcolor(co11); 
       cout << "co11" << endl; 
    
       textcolor(co12); 
       cout << "co12" << endl; 
    
       textcolor(co13); 
       cout << "co13" << endl; 
    
       textcolor(co14); 
       cout << "co14" << endl; 
    
       textcolor(co15); 
       cout << "co15" << endl; 
    
       textcolor(co16); 
       cout << "co16" << endl; 
    
       textcolor(co17); 
       cout << "co17" << endl; 
    
       textcolor(co18); 
       cout << "co18" << endl; 
    
       textcolor(co19); 
       cout << "co19" << endl; 
    
       textcolor(co20); 
       cout << "co20" << endl; 
        
       textcolor(co15); 
       cout << "Press any key to continue... ";    
       cout << flush; 
       getch(); 
        
       return 0; 
    }

  11. #11
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    are they using C++ concept ?

  12. #12
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    yes, the code above is written in c++
    but you can use the WinAPI in C also...
    just put some printf(); for the cout << should work also

  13. #13
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    dune i just wanted to say that that piece of code is not a timesaver why dont u use a loop to cycle trhough the colors ??
    Code:
    for(color=0;color<whatever;color++)

  14. #14
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    i just wanted to show a simple way

  15. #15
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109

    Talking

    i c

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  2. glut text rendering in wrong color
    By ichijoji in forum Game Programming
    Replies: 1
    Last Post: 10-31-2005, 10:02 PM
  3. VC++ setting text color of a button
    By 7stud in forum Windows Programming
    Replies: 5
    Last Post: 10-14-2004, 12:04 PM
  4. Edit Text color for specific lines
    By JaWiB in forum Windows Programming
    Replies: 7
    Last Post: 07-08-2004, 04:03 PM
  5. Text color
    By wickedclownz in forum C++ Programming
    Replies: 5
    Last Post: 06-21-2003, 04:30 AM

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