Thread: help for COLOR and GOTO function

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

    help for COLOR and GOTO function

    Guys, good day.
    i got this code and it runs but i didn't gets its syntax.
    anyone have an explanation or data about this?
    thanks.
    i am using bloodshed dev c++ compiler
    you are very much appreciated.


    Code:
    void color(int colorNum)
    {
             //colors
             HANDLE  hConsole; 
             hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 
             SetConsoleTextAttribute(hConsole, colorNum);
             //colors
    }
    
    void gotoxy(int x, int y)
    {
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    }
    Last edited by jerico; 03-09-2011 at 06:28 AM.

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Quote Originally Posted by jerico View Post
    anyone have an explanation or data about this?
    What do you need?

    EDIT: Certainly a new compiler!
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    15
    i need an explanation about the syntax of this:
    Code:
    void color(int colorNum)
    {
             //colors
             HANDLE  hConsole; 
             hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 
             SetConsoleTextAttribute(hConsole, colorNum);
             //colors
    }
    
    void gotoxy(int x, int y)
    {
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    }
    why is it in that format?
    thanks

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    HANDLE is something like pointer to "something", here the console.
    COORD is a struct with a "x" and a "y" member.

    What do you mean by format? Its indentation?
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    15
    i mean how it is contruct.

    void color(int colorNum)
    {
    //colors
    HANDLE hConsole;
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, colorNum);
    //colors
    }

    for example:
    why is it (hConsole = GetStdHandle(STD_OUTPUT_HANDLE)
    is declared as this.
    i mean i want to know what is the required format for color and for goto function.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You figure it out by reading about each function on MSDN. They're all Win32 API calls.
    GetStdHandle Function (Windows)
    SetConsoleTextAttribute Function (Windows)
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM

Tags for this Thread