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
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
{
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
Add Rich 5
Remove 1
Remove 7
Add Mind 2
Remove 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
