Question: I have some code in c++ and I am getting an error when running the scripts I am given. I am getting an error on

I have some code in c++ and I am getting an error when running the scripts I am given. I am getting an error on line 10 and it says Aprog command not found. I am ussing linux system and using a basic text editor to write my c++ code. I am getting an output file to show up and be created but it is empty every time I run the scripts. Next paragraph is the instructions for what I am supposed to do.

You are to read the input data into an appropriate vector and then dump the data using an appropriate function. You will get 5 points for doing this and for having your name and other boilerplate attribution at the top of each program file.

You will get zero points if you dont do the right read/write or if you dont have your name in each file.

My code is listed below.

#include #include #include using namespace std;

void readFile(vector &myvector) { float value = 0; fstream file; file.open("xinput.txt"); while (file >> value) { //cout << value << endl; myvector.push_back(value); } file.close(); }

void writeFile(vector &myvector) { ofstream file; file.open("xoutput.txt"); vector::iterator it; for (it = myvector.begin(); it < myvector.end(); it++) { file << *it << endl; } file.close(); }

int main() {

vector myvector; vector::iterator it; readFile(myvector); //Read data from file to vector writeFile(myvector); //write data from file from vector

for (it = myvector.begin(); it < myvector.end(); it++) { //print the data from vector which has read from input file xinput.txt cout << *it << ' '; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!