0
std::string s = "65//3";
std::istringstream indexBlock(s);

for (int i = 0; i < 2; i++) {
    int index = 0;
    indexBlock >> index;
    std::cout << index << std::endl;
}

I would expect the output of the cout to be:

output:
65
3

as I thought the stream iterates through the ints when passing it through '>>'. However the actual output is:

output:
65
0

Can someone please explain what is happening and how I might go about changing it to get the desired result.

Thank you.

Edited by jackshannon4

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by jackshannon4
0

OK, so a friend answered this for me. It is because istringstream uses whitespace as the delimiter. I'll be using getline() instead so I can set my own.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.