C++ 读取文件

 1 #include <fstream>
 2 #include <iostream>
 3 #include <string>  
 4 #include <vector>  
 5 #include <sstream> 
 6 using namespace std;
 7 
 8 int main()
 9 {
10     vector<float>nums;
11     float cirle[] = { 0 };
12     ifstream inFile("E:\1.csv", ios::in);
13     if (!inFile)
14     { //打开失败
15         cout << "error opening source file." << endl;
16         return 0;
17     }
18     while (!inFile.eof())//没有数据
19     {
20         int i = 0;
21         inFile >> cirle[i];
22         nums.push_back(cirle[i]);
23     }
24     int c = nums.size();
25     cout << c << endl;
26     inFile.close();
27     
28 }
29     
30 
31     
原文地址:https://www.cnblogs.com/hsy1941/p/11281972.html