Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 18th, 2007, 12:12 AM
Authorized User
 
Join Date: Oct 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mastrgamr
Default use enter key to exit

how do i use the entee button to exit a program, lookie here:

#include <iostream.h>
using namespace std;

int main() {
    unsigned char x[9];
    cout<<"Input an 8 letter or less password: ";
    cin>>x;
    cout<<"Your password was: "<<x<<"\n";

cin.get(); <-----------------|
                             |
return 0; |
} |
                             |
i thought that would do it!. |
y not? ----------------------|

isnt cin.get() supposed to do it?:(

Mŧ~|~®GÃ(v)R~
__________________
-Stuart Smith
Reply With Quote
  #2 (permalink)  
Old January 18th, 2007, 10:50 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Geo121
Default

unfotunately cin.get doesn't do it.

There are two ways I know of to use the enter key to exit

the easy way(janky) and the hard way(fancy)

when you use cin.get you are just saying cin pretty much

which will continue to wait until the user enters a value

if you want to do the lazy way just create a loop where you use cin and they have to enter a value of any kind to continue

or the fancy way is to implement the Win322 API if you have never used the API before I suggest you look into it I can give a good tutorial and some of my own personal examples

~ Geo

~ Don't take life too seriously, you'll never get out alive!
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Enter Key Event (Enter Key Only) Coby Excel VBA 0 February 6th, 2008 09:55 PM
How would you determine the "ENTER' key? mcinar HTML Code Clinic 15 March 24th, 2005 10:55 PM
Enter key vs Click Button akibaMaila VB.NET 2002/2003 Basics 1 January 14th, 2005 12:49 PM
Enter Key rwalker VB How-To 5 April 7th, 2004 11:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.