cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
executing a function by user input???
executing a function by user input???
Jul 31, 2011 at 4:44am
Jul 31, 2011 at 4:44am UTC
metulburr
(585)
How would you have a function execute only by the user inputing specific characters (like info) anywhere in the program, regardless of what function was currently being executed.
and then return to that spot in the function that the were at after.
Jul 31, 2011 at 11:07am
Jul 31, 2011 at 11:07am UTC
hamsterman
(4538)
You could append
if
( my_input ==
"info"
) do_stuff_with_info();
to every place where you have input, but that would be just ludicrous.
You could write a function get_input() which would check if the user entered "info" and use that instead of std::getline.
You could structure your program in such way that you only have input in one place. You would probably use state variables to make it work..
Topic archived. No new replies allowed.