cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Cin.peek() Help
Cin.peek() Help
Sep 10, 2016 at 4:34pm UTC
fivestar
(180)
"So, to enter the point (3,-4), the user should be able to enter any of: (3,-4), 3,-4), (3,-4, (3 -4), 3,-4, 3 -4), (3 -4, or even 3 -4."
My teacher told us to use the cin.peek() function to approach this problem but i cant find any resources that help with this topic.
Sep 10, 2016 at 6:08pm UTC
EtDecius
(71)
Check out
http://www.cplusplus.com/reference/istream/istream/peek/
I suspect your teacher recommended using cin.peek() to determine if the next character will be a symbol (like a parenthesis) or a digit. Once you know the type, extract it to the appropriate char or number variable via cin >> or cin.get()
Sep 17, 2016 at 2:06am UTC
fivestar
(180)
That is what i am trying to do. The tutorials dont really help me. Can you give a simple example that uses cin.peek()..
Topic archived. No new replies allowed.