1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| #include <iostream>
#include <vector>
#include <fstream>
#include <string>
struct Data
{
std::string name_{};
double x_{};
double y_{};
};
int main()
{
int i;
std::ifstream file("points.txt");
if(!file)
{
std::cerr << "file not found" << std::endl;
return 1;
}
std::vector<Data> datas;
Data data;
while(file >> data.name_ >> data.x_ >> data.y_)
{
datas.push_back(data);
}
//ensuite accès avec datas[i]
for (i=1;i< 10;i++)
{
printf("%f \n", datas[i]); // Probleme pour visualiser les donnees
}
} |
Partager