I've been attempting to use the C++ stringstream class to do some relatively simple string manipulations, but I'm having a problem with the get() method. For some reason whenever I extract the output character by character it appends a second copy of the final letter.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
stringstream ss("hello");
char c;
while(!ss.eof()) {
ss.get(c);
cout << "char: " << c << endl;
}
return 0;
}
The output from the program is:
char: h
char: e
char: l
char: l
char: o
char: o
Any help you can give me on this would be appreciated.