c++テキストから行ごとに読み出し、読み出した行をスペースで分割する
1774 ワード
ifstream tf("tf.obj", std::ios::in);//
char s[50] = {0};
string v = "";
string x = "";
string y = "";
string z = "";
for (int i = 0; i < nstrands; i++)
{
for (int j = 0; j < r.strands[i].size(); j++)
{
tf.getline(s, sizeof(s));//
stringstream word(s);// str , str word
word >> v;
word >> x;
word >> y;
word >> z;
//string float
float a = atof(x.c_str());
float b = atof(y.c_str());
float c = atof(z.c_str());
r.strands[i][j][0] = a;
r.strands[i][j][1] = b;
r.strands[i][j][2] = c;
}
}