Question: void InputDatapoints(vector one, vector all, unsigned int num, string fileName, ifstream& inFile) { string line: inFile.open(fileName); cout < < test1 < < endl; while (getline(inFile,
void InputDatapoints(vector one, vector> all, unsigned int num, string fileName, ifstream& inFile) {
string line:
inFile.open(fileName);
cout << "test1" << endl;
while (getline(inFile, line)) {
cout << "test2" << endl;
stringstream ss (line);
while (ss >> num) {
one.push_back(num);
cout << "test3" << endl;
}
all.push_back(one);
cout << "test4" << endl;
}
inFile.close()
return;
}
So basically, I'm writing a program in c++ that read lines of unsigned ints. You will not lnow ahead of time how much ints, which are separated by spaces, " " , are in each line, you are reading these from files. However if one line has two ints, then the rest of the lines im the file do, and then if another file has a line with three ints, then the other line in the particular file do too. So this is a function I wrote, InputDatapoints, and I output "tests".
I run the program and only "test1" shows up. "test2", "test3", and "test4" should be showing up too, but they don't. what is wrong with my code?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
