Question about istringstream.getline method.
Hi, everyone!
After invoking getline, I want to know what is appended at
the end of "output" in my case. It seems it is not \0. But
"strlen" function returns OK.
Output is:
--------
12
2
50
3456789
7
57
123456789
9
57
--------
Source codes:
--------
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
char input[] = "12\n3456789\n123456789";
char output[30];
istringstream is(input);
while (is.getline (output, sizeof (output), '\n'))
{
cout << output << endl;
cout << strlen (output) << endl;
if (0 == output [strlen (output) - 1])
{
cout << "Null is appended! " << endl;
}
cout << unsigned int (output [strlen (output) - 1]) << endl;
}
return 1;
}
--------
Thanks in advance,
George