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
Question about stringstream
Question about stringstream
May 10, 2015 at 2:15pm UTC
kkk2
(1)
Hi everyone,
An exercise's example says:
1
2
3
4
5
6
int
sum_int(string cmd){ stringstream ss (cmd); ...... }
but what the line "stringstream ss (cmd);" means?
why is used the syntax ss(cmd)??
thank you !!
Last edited on
May 10, 2015 at 2:16pm UTC
May 10, 2015 at 2:52pm UTC
Peter87
(11238)
It creates a stringstream variable (object) named
ss
, and the string
cmd
is passed to the constructor. After this you can read from ss using >> the same way you read user input from cin, but the input instead comes from the string
cmd
.
Topic archived. No new replies allowed.