I am trying to get the amount of lines in a file in order to make an array to store the characters of each line. I think the problem is with the two while loops iterating at the same time.
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::string;
int main(int argc, char *argv[]){
cout << "input file" << endl;
string file;
cin >> file;
ifstream inFile;
inFile.open(file, ios::in);
cout << "success1";
if (inFile.is_open()) {
vector<double> inputs;
string line;
string s;
int current;
int sTotal;
while(!inFile.eof()) {
getline(inFile, s);
sTotal++;
}
while (!inFile.eof()) {
getline(inFile, line);
cout << "success2";
char *lineArr = new char[line.length()][sTotal];
for(int j = 0;j < sTotal;j++){
for (int i = 0; i < sizeof(lineArr); i++) {
lineArr[i] = line[i];
}
}
}
}else cout << "fail";
}
Any help would be appreciated. Im probably looking at this all wrong.