Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (walters):

how to terminate a while loop in c++ using characters zzz not a string and without using an array

OpenStudy (walters):

@nubeer

OpenStudy (espex):

Could you clarify your question? Terminating a programming structure (while loop) is not something you can do without rewriting the compiler, so that must not be what you're looking to do.

OpenStudy (walters):

what i mean is that the program should terminate when the user input zzz of which the input is of type char .ie if maybe we where giving the sentinel value as z only it will be easy to terminate while ( input != 'z') { } but on this program instead of having one z i am having zzz of which z is of type char but zzz is no longer char.and according the question they are saying do not change the input type meaning i must tread it as char all along.

OpenStudy (anonymous):

just set the condition for exit to (String somestring=="zzz") while ( input != "zzz") just note that the input line should be for strings not chars

OpenStudy (rsmith6559):

If you're input is of type char, you could use some really funky char as a sentinel. I kind of like tildes for something like this. "zzz" can't be described as anything but an array of char or a string. char is a single byte data type.

OpenStudy (espex):

If you are needing to keep your input as a char, but need to grab multiple characters, could you use get() and pull the input into a buffer? You could then parse the buffer and see how many characters were entered and evaluate them.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!