I've noticed a strange behaviour with the very simple program just below.
#include <iostream>
#include <sstream>
#include <string>
int main(void)
{
std::string data = "o BoxModel\nv 1.0f, 1.0f, 1.0f\nv 2.0f, 2.0f, 2.0f\n";
std::istringstream iss(data);
std::string line;
std::string type;
while (std::getline(iss, line, '\n'))
{
iss >> type;
std::cout << type << std::endl;
}
getchar();
return (0);
}
The output is the following :
v
v
v
But I want the following one :
o
v
v
I tried this solution :
#include <iostream>
#include <sstream>
#include <string>
int main(void)
{
std::string data = "o BoxModel\nv 1.0f, 1.0f, 1.0f\nv 2.0f, 2.0f, 2.0f\n";
std::istringstream iss(data);
std::string line;
std::string type;
iss >> type;
std::cout << type << std::endl;
while (std::getline(iss, line, '\n'))
{
iss >> type;
std::cout << type << std::endl;
}
getchar();
return (0);
}
But the output is the following :
o
v
v
v
Does anyone can help me, please ? Thanks a lot in advance for your help.