Search:
Forum
General C++ Programming
If/Switch statement that always runs
If/Switch statement that always runs
Oct 21, 2011 at 10:03pm UTC
jmlpor98
(5)
I am making a project, and there are multiple areas in the project where the user enters something, but every time I want it to check for something. Is there a way to make an if or switch statement that will always run for every cin >> ?
Oct 21, 2011 at 10:07pm UTC
Duthomhas
(13200)
Make it a function, and call it every time you use
cin
.
Good luck!
Oct 21, 2011 at 10:40pm UTC
jmlpor98
(5)
Thanks!
Oct 22, 2011 at 2:37am UTC
iperetta
(10)
Actually, you could include cin in your function:
1
2
3
4
5
bool
checkSomething(
int
&var){ cin >> var;
if
(???)
return
true
;
else
return
false
; }
Assuming every cin acts on the same variable type.
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs