Compsci II HW #2

My problem is that I need to run the program 5 times but it wont repeat even though i have a for loop in my main


#include<iostream>
#include<string>


using namespace std;

void input(string &operation)
{
cout<<"What is your operation?"<<endl;
getline(cin,operation);


}
void output(string &operation)
{
string a;
string b;
if(operation[0]=='D')
{
string cell=operation.erase(0,7);
string b=cell.substr(4,4);
string a=cell.substr(0,4);
cout<<a+a<<"and"<<b+b<<endl;
}
if(operation[0]=='A')
{
int n=operation[3]-48;
string cell=operation.erase(0,5);
string a=cell.substr(n,8-n);
string b=cell.substr(8-n,n);
cout<<a+b<<endl;
}
if(operation[0]=='S')
{
int n=operation[8]-48;
string cell=operation.erase(0,10);
string c=cell;
string a=cell.erase(0,n);
string b=c.erase(0,8-n);
cout<<a+b<<endl;
}

}
int main()
{
for(int o=0; o<5; o++)
{
string operation;

input(operation);
output(operation);
}
return 0;
}
Topic archived. No new replies allowed.