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
string
string
Jul 3, 2013 at 7:46am UTC
tdk93
(43)
For the following types of input
ira ira
( two words separated by a space)
i want to store two words separated by space in two different strings, so i used the following code
1
2
3
4
5
string a,b; getline(cin, a,
' '
); getline(cin, b); cout << a.length(); cout << b.length();
but when i calculate the length of the string for the given case ( that is- "ira ira" ) it gives the answer as 4 and 3 respectively
Why doesn't it give answer as 3 and 3??
Last edited on
Jul 3, 2013 at 7:52am UTC
Jul 3, 2013 at 8:14am UTC
mutexe
(2372)
stick a breakpoint on line 4 and examine a and b.
Topic archived. No new replies allowed.