so, to be honest, I'm a student at drexel. I have a comp sci problem. My program works fine except for:

if (stuAns[i]!="A" || stuAns[i] !="B")
		{
			i--;
			cout<< "Your answer must be capital A or capital  
                       B"<<endl;
		}

this is embedded in a for loop. Also, it works if I don't use the ||. Do I have to overload that? I really really really really don't want to. But I can.

Recommended Answers

All 3 Replies

How is stuAns declared?

If it is a char array, like this:

char stuAns[10];

or a string like this:

string stuAns;

or a vector like this:

vector<char> stuAns;

then "A" and "B" should be 'A' and 'B'.

If that's not it, then I'd request you post more code.

Also, it works if I don't use the ||.

What does this mean?

I'm not sure what type of a vector stuAns is.
If it is a vector of char*, you have to use strcmp() instead of checking with the operator !=.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.