hi guys,
I am trying write a simple program which reads from a text file line by line,
and convert each line into an integer and store it into an array.
My textfile is basically a list of numbers. So each line holds a number.
For some reason it is saying that there is no suitable conversion function from std::string to constant char.
#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
#include <fstream>
using std::ifstream;
#include <vector>
#include <string>
using namespace std;
int main() {
vector<int> arr;
ifstream myReadFile;
myReadFile.open("C:\\time\\time.txt");
string line[256];
for(int i = 0; myReadFile.good(); i++)
{
getline( myReadFile, line[i]);
cout<< line[i] <<endl;
int x;
string y = line[i];
x = atof (y) ;
cout<< x <<endl;
}
myReadFile.close();
return 0;
}