cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Reading in the input as a string
Reading in the input as a string
Sep 8, 2013 at 10:25pm UTC
SlenderMan
(69)
complete
Last edited on
Sep 8, 2013 at 11:12pm UTC
Sep 8, 2013 at 10:31pm UTC
Vermacian55
(10)
You could use getline found in <sstream>.
Use it like this
1
2
string phrase; getline(cin,phrase);
Last edited on
Sep 8, 2013 at 10:34pm UTC
Sep 8, 2013 at 10:36pm UTC
SlenderMan
(69)
ive tried that but i just messes my program up. It skips over another point where you're supposed to enter something
Sep 8, 2013 at 10:40pm UTC
Vermacian55
(10)
It does? Might just be something in your code. Could you show it?
Sep 8, 2013 at 10:45pm UTC
Zhuge
(4664)
Highly likely you've used cin>> before it, which if you pressed enter would leave a newline character in the buffer. getline() reads that as an empty line. But to be sure, we'd need to see the code as Vermacian55 asked.
Topic archived. No new replies allowed.