I am trying to read a text file of the format:
5
1.00   0.00
0.75   0.25
0.50   0.50
0.25   0.75
0.00   1.00
The code is:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
int totalDataPoints; // this should be the first line of textfile i.e. 5
std::vector<double> xCoord(0); //starts from 2nd line, first col
std::vector<double> yCoord(0); //starts from 2nd line, second col
double tmp1, tmp2;
int main(int argc, char **argv)
{
    std::fstream inFile;
    inFile.open("file.txt", std::ios::in);
    if (inFile.fail()) {
        std::cout << "Could not open file" << std::endl;
        return(0);
    } 
    int count = 0;
     while (!inFile.eof()) { 
         inFile >> tmp1;
         xCoord.push_back(tmp1);
         inFile >> tmp2;
         yCoord.push_back(tmp2);
         count++;
     }
     for (int i = 0; i < totalDataPoints; ++i) {
         std::cout << xCoord[i] << "    " << yCoord[i] << std::endl;
     }
    return 0;
}
I am not getting results. My final aim is to put this as function and call the x, y values as an object of a class.
 
     
     
    