I need help with using the cin command\function. Any time I try to use it outside of the main function it does not work what am I doing wrong?
Brent.tc
0
Junior Poster in Training
Recommended Answers
Jump to PostHmm.. looks like you really new to programming.
"main()" as you say is the entry point for the program you write. Syntactically and technically you cant write anything outside main except macros, function definations and declarations, and global variables.
So if you want to write "cin" outside main …
Jump to Post1) Post some code. Unfortunately, crystal balls are a bit out of the budget, so we can't see what's wrong.
2) A 9-year old book is... well, almost antiquated. Consider getting a new one, since C++ has been standardized since your book was published. Some compilers may have problems …
Jump to PostI think you skip the next cin because you still have the enter pressed.
try putting
cin.ignore();
in front of it.Edit: Do you to want answer on the questions in the code?
All 9 Replies
Brent.tc
0
Junior Poster in Training
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
Brent.tc
0
Junior Poster in Training
Infarction
503
Posting Virtuoso
Brent.tc
0
Junior Poster in Training
Anonymusius
5
Posting Whiz in Training
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
Brent.tc
0
Junior Poster in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.