600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > c++ 从文本中逐行读取 并按空格对读取的一行进行分割

c++ 从文本中逐行读取 并按空格对读取的一行进行分割

时间:2019-05-22 19:52:52

相关推荐

c++ 从文本中逐行读取 并按空格对读取的一行进行分割

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;}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。