Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how to get user input in c++
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
deathscith




PostPosted: Fri Oct 17, 2008 11:38 pm   Post subject: how to get user input in c++

how do i go about getting a user input in c++, i am only familiar with turing, which in this case of turing the statement would be get <variable>, how do i go about doing this in c++
Sponsor
Sponsor
Sponsor
sponsor
md




PostPosted: Sat Oct 18, 2008 12:30 am   Post subject: RE:how to get user input in c++

you want to look into the iosteam library, specidically std::cin and std::cout

However, I must re-iterate what everyone said in the other thread, waiting for input at the end of execution is horrible practice. Just run your program from the command line like it was meant to be run. You'll develop much better programming practices and be better for it.
deathscith




PostPosted: Sat Oct 18, 2008 12:58 am   Post subject: Re: how to get user input in c++

yea, but i want to actually be able to see my program when its open, is it possible to add a delay before it shuts itself down? like in turing the

code:

delay (1000)
Ktomislav




PostPosted: Sat Oct 18, 2008 8:09 am   Post subject: Re: how to get user input in c++

1. You don't need to use std::cin. You can use
code:

using namespace std;

After including a library(s). And then you can just use
code:
cin >>variable;
cout <<variable;

2. For stopping program from closing you can use
code:

cin >>variable;

or System.Pause (not recommended).
wtd




PostPosted: Sat Oct 18, 2008 11:35 am   Post subject: RE:how to get user input in c++

That is the same thing. Concepts vs. syntax: you must understand the difference.
md




PostPosted: Sat Oct 18, 2008 11:45 am   Post subject: Re: how to get user input in c++

deathscith @ 2008-10-18, 12:58 am wrote:
yea, but i want to actually be able to see my program when its open, is it possible to add a delay before it shuts itself down? like in turing the

code:

delay (1000)


if you run your program from the command line then the window will not close when it's finished running. That is how command line programs are meant to be run.
deathscith




PostPosted: Tue Nov 11, 2008 12:12 pm   Post subject: RE:how to get user input in c++

when you say command line, do you mean cmd? (i do my programming on a windows xp computer)
wtd




PostPosted: Tue Nov 11, 2008 3:11 pm   Post subject: RE:how to get user input in c++

Yes.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: