Hi all. I want to take a set number of characters from a stringstream at a time and display them to the console as per my code below. Because of when the first blank space is reached the process terminates due to teh eofbit flag. Is there any way around this in c++.
Thank you.
#include <iostream>
#include <string>
#include <sstream>
#include <istream>
using namespace std;
int main()
{
char mychar[4];
string mystring;
stringstream mystream;
cout << "enter a string" << endl;
cin >> mystring;
mystream << mystring;
//Now view the output
while (mystream.get(mychar,4))
{
for (int i = 0; i < 3; i++)
{
cout << mychar[i];
}
}
}