Do-While Loop Implementation

I have an assignment where I have to create a program in which I use Stacks to evaluate post-fix mathematical expressions. I have to create the Stacks myself instead of using them from a library in order to understand them better. The only problem is I want to have the user interact with a menu of multiple functions, and the do-while loop in FUN_COMMAND() won't work, so the user can only do one thing from the menu (as the loop runs once). I have the code below. Is there something I'm missing or need to change in the loop itself or is it outside the loop? *Note* All the variables before the main are global to the other functions which I havent included.

Code:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

//Functions used
void FROM_FILE ();
void MENU ();
void FUN_COMMAND ();

void CREATE_S ();
void CREATES_S ();
void PUSH_X_S ();
void POP_S ();
void EMPTY_S ();
void EVAL_X_S ();
void EVALS_S1_S2 ();
void DISPLAY_S ();
void FINISH ();

int A[20], B[20], C[20], ForFile[20];
string X[20], Y[20], Z[20];
char eval[20];
char YesNo, StackPoint, command;
int CountA = -1, CountB = -1, CountC = -1, CountX = -1, CountY = -1, CountZ = -1, AuxCount, evalCount, CountForFile;

string fname, expression;
ifstream ins;

int main ()
{
cout << "Would you like to use an expression from a file?" << endl << "*Note* A postfix expression from file will be automatically evaluated" << endl << "(y/n): ";
cin >> YesNo; cout << endl;

if (YesNo == 'y' || YesNo == 'Y')
{
FROM_FILE ();
}
else if (YesNo == 'n' || YesNo == 'N')
{
FUN_COMMAND ();
}

FINISH ();

return 0;
}

void FROM_FILE ()
{
//Arbitrary function
}

void FUN_COMMAND ()
{
cout << "To input any expressions, at least one integer stack and one string stack must be created." << endl;
cout << "---------------------------------------… << endl;
cout << "Select the number from the menu below." << endl;
cout << "1.CREATE S........creates empty integer stack" << endl;
cout << "2.CREATES S.......creates empty string stack" << endl;
cout << "---------------------------------------… << endl;
cout << "Command Number: "; cin >> command;

if (command == '1')
{
CREATE_S ();
}
else if (command == '2')
{
CREATES_S ();
}
else
{cout << "Improper input.." << endl;}

cout << "To input any expressions, at least one integer stack and one string stack must be created." << endl;
cout << "---------------------------------------… << endl;
cout << "Select the number from the menu below." << endl;
cout << "1.CREATE S........creates empty integer stack" << endl;
cout << "2.CREATES S.......creates empty string stack" << endl;
cout << "---------------------------------------… << endl;
cout << "Command Number: "; cin >> command;

if (command == '1')
{
CREATE_S ();
}
else if (command == '2')
{
CREATES_S ();
}
else
{cout << "Improper input.." << endl;}

MENU ();

do
{
cout << "Type a command number..Scroll up to view commands if needed" << endl;
cout << "*Note* An integer and string stack must be created to use other commands" << endl;
cout << "Command Number: "; cin >> command;

if (command == '1')
{
CREATE_S ();
}
else if (command == '2')
{
CREATES_S ();
}
else if (command == '3')
{
PUSH_X_S ();
}
else if (command == '4')
{
POP_S ();
}
else if (command == '5')
{
EMPTY_S ();
}
else if (command == '6')
{
EVAL_X_S ();
}
else if (command == '7')
{
EVALS_S1_S2 ();
}
else if (command == '8')
{
DISPLAY_S ();
}
else if (command == '9')
{
cout << "Exiting.." << endl;
}
else
{cout << "Improper input.." << endl;}

} while (command =! '9');
}

void MENU ()
{
cout << endl;
cout << " Command Menu" << endl;
cout << "-----------------------------" << endl;
cout << "Command Function" << endl;
cout << "-----------------------------" << endl;
cout << "1.CREATE S........creates empty integer stack" << endl;
cout << "2.CREATES S.......creates empty string stack" << endl;
cout << "3.PUSH X S........pushes element x onto stack" << endl;
cout << "4.POP S..........pops top element from stack" << endl;
cout << "5.EMPTY S.........checks if stack is empty" << endl;
cout << "6.EVAL X S........evaluates string x using integer stack and displays result" << endl;
cout << "7.EVALS S1 S2.....pops postfix from string stack and evaluates integer stack displaying results" << endl;
cout << "8.DISPLAY S.......displays contents of stack, top to bottom" << endl;
cout << "9.QUIT............displays contents of existing stacks and terminates program" << endl;
cout << "------------------------------------------------------------------------------" << endl;
}

//After this are all the other functions which (hopefully) are arbitrary to the problem
Topic archived. No new replies allowed.