D
Diwa
Does istringstream require one whitespace at a min ?
In the code below I expected "first" and "secondline" to be printed.
Only "first" got printed.
The code is as follows:
// -----------------------------------------------------------------
#include <iostream> // std::cout
#include <fstream> // ifstream
#include <sstream> // stringstream
#include <string>
int main( )
{
std::string cfgSvrName;
std::istringstream iss_1("first line");
std::istringstream iss_2("secondline");
iss_1 >> cfgSvrName;
if (iss_1.good( ))
std::cout << "cfgSvrName - ******" << cfgSvrName << "******\n";
iss_2 >> cfgSvrName;
if (iss_2.good( ))
std::cout << "cfgSvrName - ******" << cfgSvrName << "******\n";
}
// -----------------------------------------------------------------
Executing it gives
// -----------------------------------------------------------------
$ ./a.out
cfgSvrName - ******first******
// -----------------------------------------------------------------
Thanks
Diwakar
In the code below I expected "first" and "secondline" to be printed.
Only "first" got printed.
The code is as follows:
// -----------------------------------------------------------------
#include <iostream> // std::cout
#include <fstream> // ifstream
#include <sstream> // stringstream
#include <string>
int main( )
{
std::string cfgSvrName;
std::istringstream iss_1("first line");
std::istringstream iss_2("secondline");
iss_1 >> cfgSvrName;
if (iss_1.good( ))
std::cout << "cfgSvrName - ******" << cfgSvrName << "******\n";
iss_2 >> cfgSvrName;
if (iss_2.good( ))
std::cout << "cfgSvrName - ******" << cfgSvrName << "******\n";
}
// -----------------------------------------------------------------
Executing it gives
// -----------------------------------------------------------------
$ ./a.out
cfgSvrName - ******first******
// -----------------------------------------------------------------
Thanks
Diwakar