Hey, I'm guessing my bool never returns true for some reason. There's no compiler error, it just continually prints back that the operator is invalid, even when the user enters a valid operater. I know I'm missing something glarlingly obvious in this section of my program, but I just can't spot it for the life of me:
Code:
#include <iostream>
#include <cstring>
using namespace std;
bool OpStatus(false);
char TestOp, UseOp;
int i;
void IsValidOp(char TestOp, int i);
void main()
{
while (1)
{
cout << "Enter desired operation: ";
cin >> TestOp;
IsValidOp(OpStatus,i);
if (OpStatus==false)
{
cout << "Invalid operator. Try again." << endl;
continue;
} else TestOp = UseOp;
}
}
void IsValidOp(char TestOp, int i)
{
char ValidOp[] = "+-*/cCxX";
for (i=0; OpStatus=false, (i<strlen(ValidOp)); i++)
{
if (TestOp==ValidOp[i])
OpStatus = true;
}
}
Comment