Question

Discussion in 'C' started by techinspiration, Apr 15, 2010.

  1. techinspiration

    techinspiration New Member

    Joined:
    Feb 14, 2010
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    0
    How could i generate the colors in the C language.
    Please help me in this matter.
     
  2. gagandeep1

    gagandeep1 New Member

    Joined:
    Jan 23, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    to generate colors use inbuilt color function
    setcolor (color code)
    i do not no exact . it may be color (color code)
    color code is an integer value for each color.
     
  3. umartayyabkhan

    umartayyabkhan New Member

    Joined:
    Jan 21, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Electrical Engineering Student
    Location:
    Peshawar
    Home Page:
    http://www.al-quran.kk5.org
    This is console colour code.You may use it for colour .

    Code:
    #include <stdio.h>
    #include <windows.h>
        int main(){
                 HANDLE  hConsole;
                 	int k;   
                     hConsole = GetStdHandle(STD_OUTPUT_HANDLE);  
                      
                       for(k = 1; k < 350; k++)  
                       {    SetConsoleTextAttribute(hConsole, k);
                           printf("%3d  %s\n", k, "I want to be nice today!"); 
                            } 
                              getch(); 
                              } // wait  return 0;}
    
     
  4. imported_Muhammad usman

    imported_Muhammad usman New Member

    Joined:
    Jan 23, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    this code do not work and gives 8 error
     
  5. umartayyabkhan

    umartayyabkhan New Member

    Joined:
    Jan 21, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Electrical Engineering Student
    Location:
    Peshawar
    Home Page:
    http://www.al-quran.kk5.org
    Brother this Code is Operating system dependent,it works fine on my 32 bit pc.
    I can give you another code for this you can try this by changing 2a to some other n0 or letter..
    Code:
    #include <stdio.h>
    int main(){
        
        system("color 2a"); //try to change 2a for colour changes
        printf("HELLO WORLD");
        getch();
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice