InitHandle Problem

This is a discussion on InitHandle Problem within the C++ Programming forums, part of the General Programming Boards category; Well, I have two handles. One for the keyboard and another for the screen(Im working on a new game) and ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    26

    Unhappy InitHandle Problem

    Well, I have two handles. One for the keyboard and another for the screen(Im working on a new game) and I have a function that initializes them defined in a .cpp file. But whenever I try to InitHandles (); It acts as though they dont even exist?
    "Borland Rocks!"

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    InitHandles() - where are you getting that from?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Nor
    Nor is offline
    h ֆhr s Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299
    which compiler are you using?
    and cna you post some code?
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    26
    Im using VC++ 6.0. Here is what InitHandles() looks like

    int InitHandles(void)
    {
    HANDLE q_Screen;
    HANDLE q_Keyboard;
    q_Screen=GetStdHandle(STD_OUTPUT_HANDLE);
    q_Keyboard=GetStdHandle(STD_INPUT_HANDLE);

    return (0);
    }
    "Borland Rocks!"

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    26
    sorry for not using tags, il use them from now on
    "Borland Rocks!"

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    But whenever I try to InitHandles (); It acts as though they dont even exist?
    How about actually telling us what happens? Do you get an error at compile time? Do you get an error at run time? What exactly? Just saying "it acts like..." doesn't tell us anything.

    That being said, if that is all your function does, how on earth do you expect it to actually do something?

    Let's look at this function:
    Code:
    int InitHandles(void)
    {
        HANDLE q_Screen;   /* local variable */
        HANDLE q_Keyboard; /* local variable */
        q_Screen=GetStdHandle(STD_OUTPUT_HANDLE);
        q_Keyboard=GetStdHandle(STD_INPUT_HANDLE);
    
        return (0); /* local variables destroyed */
    }
    I can only assume that "acts like they don't exist" means that in fact you end up with no handles. Well, that makes sense, since your local variables are toast after this function ends.

    Furthermore, you never actually check or do anything with either of these variables, other than temporarily assign them a value.

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

  7. #7
    Registered User
    Join Date
    Jul 2003
    Posts
    26
    At compile time I get three errors and here they are:

    error C2556: 'int __cdecl InitHandles(void)' : overloaded function differs only by return type from 'void __cdecl InitHandles(void)'

    error C2371: 'InitHandles' : redefinition; different basic types

    error C2065: 'q_Screen' : undeclared identifier
    "Borland Rocks!"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM

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