直接看代码示例
// 读取操作
vector<Point3f> w3Point;
vector<Point2f> uvSL;
float tempx=0.0, tempy=0.0;
FILE *fp;
errno_t err = fopen_s(&fp, "cvSideCenter.txt", "rt"); //读取文件数据
cout << err << endl;
while (!feof(fp))
{
fscanf_s(fp, "%f %f\n", &tempx,&tempy);
//cout << tempx << "..." << tempy << endl;
Point2f temp(tempx, tempy);
uvSL.push_back(temp);
}
fclose(fp);
// 写入操作
err = fopen_s(&fp, "worldCenter.txt", "w+"); //写入文件数据
cout << err << endl;
for (int i = 0;i < w3Point.size();i++)
{
fprintf_s(fp, "%.2f %.2f %.2f\n", w3Point.at(i).x, w3Point.at(i).y, w3Point.at(i).z);
}
fclose(fp);