码迷,mamicode.com
首页 > 编程语言 > 详细

C++文本的读取和写入

时间:2014-07-01 13:41:01      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   2014   os   c++   

 1 #include <iostream>
 2 #include <sstream>
 3 #include <fstream>
 4 #include <string>
 5 int main(int args, char **argv)
 6 {
 7     std::ifstream fin("GetDltWDu_7_list.txt", std::ios::in);
 8     /*std::ofstream fout("2014_6_20.txt",std::ios::app);*/
 9     std::ofstream fout("WDuStruct_7.txt");
10     char line[1024]={0};
11     std::string x = "";
12     std::string y = "";
13     std::string z = "";
14     std::string w = "";
15     std::string v = "";
16     int i = 0;
17     while(fin.getline(line, sizeof(line)))
18     {
19     std::stringstream word(line);
20     word >> x;
21     word >> y;
22     word >> z;
23     word >> w;
24     word >> v;
25     std::cout << "  x: " << x;
26     std::cout << "  y: " << y;
27     std::cout << "  z: " << z;
28     std::cout << "  w: " << w;
29     std::cout << "  v: " << v;
30     std::cout<< std::endl;
31     double a = atof(w.c_str());
32     double b = atof(v.c_str());
33     double _Dlt = a - b;
34     /*if(i < 60000 )
35     {
36 
37     }
38     else*/
39     {
40         //s_EightDegree[2] = new WDuData(84.8024737227034f,0.1289611582564f);
41         //fout<<"s_SixteenDegree.Add( new WDuStruct.WDuData("<< a<<"f,"<<_Dlt<<"f));"<<std::endl;//生成list
42         fout<<"s_SevenDegree[" <<i <<"] = new WDuData("<<a <<"f," <<_Dlt <<"f);"<<std::endl;
43     }
44     
45     /*if(i == 65428)
46         break;
47         */
48     i++;
49     
50 
51     }
52     fin.clear();
53     fin.close();
54     system("pause");
55     return 0;
56 
57 }

 

C++文本的读取和写入,布布扣,bubuko.com

C++文本的读取和写入

标签:style   blog   color   2014   os   c++   

原文地址:http://www.cnblogs.com/felove2013/p/3817082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!