input value either string or integer c++ [on hold]


I need to write a program, which would keep asking for inputs until the word "exit" is an input. If the given input is an integer, the program should keep the integer in a vector.



(Also if the input is the word "sort" program should sort given vector and print it and if the input is the word "search x" it should search the vector and inform whether the value is in the vector.)



Besides the rest my main problem is how can I allow the input to be both either integer or string value for the further commands???



Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.



You can just cast the input into a string and let the code tell you if the input is equal == to "exit". You can also use the isdigit() function of the cctype header to check for the digits 0 1 2 3 4 5 6 7 8 and 9. Otherwise you can use a default condition to check for other input.

Popular posts from this blog

佛陀 (漫畫)

Đế Bá

文学批评