Solved

kbhit( ) problem

Posted on 2004-04-14
8
791 Views
Last Modified: 2012-05-04
friends:
theres problem with kbhit() function. my program takes input from user (from keyboard) and specifies which button he has pressed...but due to the getch the program terminates if any key is pressed..the message i get later is that there was an illegal operation and hence terminated.
can someguys help me out..
Mithun
0
Comment
Question by:mythgops
8 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 10822456
Can you please post some lines of code and the exact error messages.
0
 

Author Comment

by:mythgops
ID: 10822822

friends & experts:
 
can anyone tell me which all libraries do i need to work on windows programming..i came to know that c++ has no GUI facility..so i have to go thru the win32 api tutorials..
i have just downloaded <windows.h> and <commdlg.h> header files...so do i need to download more header files for win32 api to work on my turbo c++?
0
 

Author Comment

by:mythgops
ID: 10822871
friends & experts & Steh:

i wrote the following code:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
    return 0;
}

i got the error message as:
type mismatch in redeclaration in pascal winmain..parameter hinstance..hprevinsatnce..lpcmdline is never used
hope u could help

Mithun
0
 
LVL 13

Accepted Solution

by:
SteH earned 125 total points
ID: 10822970
Windows has a GUI facility: MFC.

but since you mention Turbo C++ you are using an older version of a borland compiler. Depending on the version of it you have either OWL or TurboVision as GUI framework.

windows.h includes several other files internally depending on defines done before. Maybe some of them are missing which define/redefine HINSTANCE or LPSTR. Normally those files should all come with the compiler. Perhaps you have to look where they are hidden. Is there a legal place for downloading them not in connection with a compiler?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 11

Expert Comment

by:Jase-Coder
ID: 10823087
try changing the calling convention to PASCAL.

#include <windows.h>

int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
0
 
LVL 13

Expert Comment

by:SteH
ID: 10823264
WINAPI should translate into PASCAL if available. VC++6 and later don't support PASCAL but WINAPI is changing linking options to achieve the same in those cases. So I would suggest to leave WINAPI as it is but try to see how WINAPI is defined in your case (do you hae the correct header file in your include search path?).
0
 
LVL 30

Expert Comment

by:Axter
ID: 10823370
If you're creating a WIN32 console application, you don't need <windows.h>

If you're trying to convert a program for Turbo C++ to VC++, the best thing to do is trying making a WIN32 console application.
It shouldn't require that much modifications.

Exactly what type of application are you trying to build, and what compiler are you using?
0
 

Author Comment

by:mythgops
ID: 10825408
am using turboc++ complier..need to start making games..
for that i need a response from key board..which unfortunately is not happening..some required header files seems to be missing.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now