The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-04-2001
Registered User
 

Join Date: Oct 2001
Location: Columbus, OH
Posts: 6
Yet Another Question

Now that I have getch() to work, I have yet another problem. BTW, thank you for answering these questions, I do ask a lot, only because I am eager to know, what is a board used for anyways

Ok, he's the problem...

#include iostream.h
#include conio.h

int main()
{

char movement;

movement = getch();

cout << movement;

if(movement == 8)
{
cout << "This is what happends when you press 8";
}

return 0;
}

So, it should print "This is what happends when you press 8", but it doesn't. I have no idea what it could be, because it looks as right as rain. Anyways, thanks for the help!

Mike
__________________
I like to play Quake
Reply With Quote
Forum Sponsor
  #2  
Old 10-04-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
Re: Yet Another Question

Quote:
Originally posted by mbolthouse

if(movement == 8)
I'm a c programmer, not a c++ programmer, but I gotta say I think that if statement needs some help. You're checking to see if movement is a decimal 8 and that's not what the 8 key transmits. In c
if(movement == '8')
would be correct. Give that a try.
Reply With Quote
  #3  
Old 10-04-2001
Registered User
 

Join Date: Oct 2001
Location: Columbus, OH
Posts: 6
Thanks!

AH-HA! Thank you Perderabo!!! It works perfectly now

Mike
__________________
I like to play Quake
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0