ofstream o_file1, o_file2; 为什么第一个写文件里面什么都没有,第二个成功?
弄的一个写文件:
ofstream o_file1, o_file2; o_file1.open("LiDAR1.txt",ios::trunc); o_file2.open("LiDAR2.txt",ios::trunc); .................. int i = 0; while (reader.ReadNextPoint()) { // Get a point liblas::Point const& point = reader.GetPoint(); if (DataID == 1) { pVertices[i].x = point.GetX() - 277085; pVertices[i].y = point.GetY() - 4180763; pVertices[i].z = point.GetZ() - 2464; pVertices[i].CVector3_DataID = DataID; o_file1<<pVertices[i].x<<" "<<pVertices[i].y<<" "<<pVertices[i].z<<"\n"; } else { pVertices[i].x = point.GetX() - 277085; pVertices[i].y = point.GetY() - 4180763+0.364; pVertices[i].z = point.GetZ() - 2464; pVertices[i].CVector3_DataID = DataID; o_file2<<pVertices[i].x<<" "<<pVertices[i].y<<" "<<pVertices[i].z<<"\n"; } i++; } o_file1.close(); o_file2.close();