C++文本的读取和写入

时间:2022-06-04 08:38:08
 #include <iostream>
 #include <sstream>
 #include <fstream>
 #include <string>
 int main(int args, char **argv)
 {
     std::ifstream fin("GetDltWDu_7_list.txt", std::ios::in);
     /*std::ofstream fout("2014_6_20.txt",std::ios::app);*/
     std::ofstream fout("WDuStruct_7.txt");
     ]={};
     std::string x = "";
     std::string y = "";
     std::string z = "";
     std::string w = "";
     std::string v = "";
     ;
     while(fin.getline(line, sizeof(line)))
     {
     std::stringstream word(line);
     word >> x;
     word >> y;
     word >> z;
     word >> w;
     word >> v;
     std::cout << "  x: " << x;
     std::cout << "  y: " << y;
     std::cout << "  z: " << z;
     std::cout << "  w: " << w;
     std::cout << "  v: " << v;
     std::cout<< std::endl;
     double a = atof(w.c_str());
     double b = atof(v.c_str());
     double _Dlt = a - b;
     /*if(i < 60000 )
     {

     }
     else*/
     {
         //s_EightDegree[2] = new WDuData(84.8024737227034f,0.1289611582564f);
         //fout<<"s_SixteenDegree.Add( new WDuStruct.WDuData("<< a<<"f,"<<_Dlt<<"f));"<<std::endl;//生成list
         fout<<"s_SevenDegree[" <<i <<"] = new WDuData("<<a <<"f," <<_Dlt <<"f);"<<std::endl;
     }

     /*if(i == 65428)
         break;
         */
     i++;

     }
     fin.clear();
     fin.close();
     system("pause");
     ;

 }