This is what i have done so far , but then I am stuck on how to display x,y or count the number of points in that file. So let's assume we have these points with test1.txt :
0,1
0,4
6,3
2,4
5,4
5,6
6,4
5,4
Thank you
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
typedef struct
{
int x;
int y;
} point;
int main()
{
ifstream input;
string filename;
cout << "Enter the file name :" << endl;
cin >> filename;
input.open(filename.c_str());
while(input.fail())
{
input.clear();
cout <<"Incorrect filename, please enter again" << endl;
cin >> filename ;
input.open(filename.c_str()) ;
}
vector<point> points;
point tmp;
while (input >> tmp.x && input >> tmp.y)
{
points.push_back(tmp);
};
cout << points.size() << endl;
return 0;
}