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;}}
600字范文,内容丰富有趣,生活中的好帮手!