Thread: Problem calling a function

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    52

    Problem calling a function

    Hello,
    I have to include a function that have been given to me in a program to set text and background color. That's the function:
    Code:
    void TextColor(int fontcolor,int backgroundcolor,HANDLE screen)
    {
       unsigned short color_attribute;
       color_attribute = backgroundcolor;
       color_attribute = _rotl(color_attribute,4) | fontcolor;
       SetConsoleTextAttribute(screen,color_attribute);
    }
    However I'm a noob and I don't know how to call it. I've tried TextColor(RED,BLACK) but compiler (dev-c++) gives me an error (to few arguments for TextColor).
    Can you help me?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Obviously it expects 3 arguments, but you only give it 2.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    52
    Obviously it expects 3 arguments, but you only give it 2.
    Thanks for the quick answer but what is supposed to be the third argument I don't know what a HANDLER is.

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    43
    I'm a noob also so take this with caution...

    Do you really want the function declared as void? I would think if you're changing the settings as you are you would want it to return something.

    experts please chime in.

    crazychile

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by JOCAAN View Post
    Thanks for the quick answer but what is supposed to be the third argument I don't know what a HANDLER is.
    I can only guess it wants the handle to the console...
    Something like:
    Code:
    TextColor( RED, BLACK, GetConsoleWindow() );
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. problem with function calling
    By Andystudent in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2004, 06:12 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM