Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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;

one.clear();

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions