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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started