A calculator help!

Started by
1 comment, last by Orochimaru 20 years ago
Hi! I just got recently into coding with C++. I''ve already been dealing with classes and that kind of stuff, but my problem mainly is, how, if I whant to code a simple calculator and I whant to enable some input keys like (-+*&/) from the keyboard, so I can do some functions, that knows what to do when the certain key is hit. thanks!!
Advertisement
char chr='' '';while (chr!=''q'') {    cin >> chr;    switch (chr) {    case ''+'':        callPlusAction();        break;    case ''-'':        callMinusAction();        break;    }}


Zorx (a Puzzle Bobble clone)
Discontinuity (an animation system for POV-Ray)
Zorx (a Puzzle Bobble clone)Discontinuity (an animation system for POV-Ray)
Cin is useful if you''re using a console, but not if you''re using the Windows API. For this you''ll want to look at the WM_KEYUP and WM_KEYDOWN messages in your message loop. The wParam returns a ''virtual-key'' scancode which refers to the key being held down (or up). Create an array to store which keys are down and which arent, then use the message loop to change them.

Worship the holy trinity that is Blitz, Babes and Beers!
Worship the holy trinity that is Blitz, Babes and Beers!

This topic is closed to new replies.

Advertisement