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;

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?

By the way, my code compiles, I did not type this code on my phone. I looked on the computer screen and typed it on my phone, so any missing semicolons or whatnot are typos from the result of human error, so I want to make it very clear to you my code compiles andif my actual code was missing any semicolon the compiled would bark at me and not output "test1". I need to find out why I only get test1, and not the others. May I remind you again my code compiles, this is a segment. I transcriped it off my computer screen. I corrected the typos, I can't send you a good picture, so I have to do it this way. So what's wrong with my code?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Determine miller indices of plane X z 2/3 90% a/3

Answered: 1 week ago