Sorry in advance if there's already a thread or if i've posted in a wrong section(??).

My question:

If i use the tolower function can i use the newly editted input and put it back to where it came from??
In effect - clarity isn't my strong point today :(
I've got a simple "do" loop that offers a restart option but only if the while criteria !=n is met. I want to get it to either accept 'N' or to read input -> change to lower case -> accept the now lower case.
Did try while ((Choice !='n')||(Choice !='N')); but it got stuck in loop.

Either solution type would be helpful. Muchos er Thankos

Recommended Answers

All 2 Replies

I think you need either: while(Choice!='n' && Choice!='N') { } Note the && (and).

OR: while(tolower(Choice)!='n') { } Also please note you are very unlikely to need the ; after the while
unless it is in a do { } while (condition); construction.
Whatever you want executed goes in the brackets.

Wowzers.
Cheers for the quick reply.
Both options worked exactly as on the tin.
So the && statement reads;
"while choice is not a and choice is not b"
as oppose to
"while choice is not (a and b) then... "?

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.