Question: I need to change this code so that it has a cant remove error message next to 0 kid. Expected output : 0 kid can't

I need to change this code so that it has a cant remove error message next to 0 kid.

Expected output :

0 kid can't remove

1 grow

2 note

3 final

4 student

#include

#include

#include

#include

#include

using namespace std;

vector vec(100);

int main() {

ifstream getfile("transaction.txt");

string line;

while (getline(getfile, line))

{

istringstream iss(line);

string command;

iss >> command;

if (command == "Add")

{

string word;

int position;

iss >> word >> position;

vec.insert(vec.begin() + position, word);

}

else if (command == "Remove")

{

int position;

iss >> position;

vec.erase(vec.begin() + position);

}

else if (command == "Print")

{

for (vector::const_iterator i = vec.begin(); i != vec.end(); ++i)

{

if (*i != "")

{

cout << *i << " ";

}

}

}

}

cin.get();

return 0;

}

transaction.txt

Add Student 0

Add Kid 0

Add Final 1

Add Grow 1

Add Note 2

Print

Add Rich 5

Remove 1

Remove 7

Add Mind 2

Remove 3

Print

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!