Archived

This topic is now archived and is closed to further replies.

A calculator help!

This topic is 5012 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites