其他分享
首页 > 其他分享> > CPP常用代码

CPP常用代码

作者:互联网

 

 

IO--写

    void DataProc_Manager::WriteXYZToFile(std::string filePath, int nPtNum, const double* lat, const double* lon, const double* height)
    {
        char buffer[1024] = "";
        FILE* fp = nullptr;

        fp = fopen(filePath.c_str(), "w");
        if (!fp) return;

        for (int i = 0; i < nPtNum; ++i)
        {
            memset(buffer, 0, 1024);
            //纬度 经度 高程
            //经纬度保留小数点后8位,精确到毫米
            sprintf_s(buffer, "%.8lf %.8lf %.3lf", lat[i], lon[i], height[i]);
            fwrite(buffer, strlen(buffer), 1, fp);
            fwrite("\n", 1, 1, fp);
        }

        fclose(fp);
    }

 

标签:fp,常用,%.,const,buffer,double,代码,int,CPP
来源: https://www.cnblogs.com/jimmy-zhang/p/16493465.html