0
How I make the player to make Complexe Imputs?
So I made a code in C++ and it calculates 2 numbers. Now I want that the player every time he/she enters the app the app will ask for imput And the imput I want to be more complexe like this "2+2*2" Using "cin" is not helping since I can only imput one number. Final question = How I can make the player to input more complex phrases with pluses and more? Having in mind I have 2 variables a and b
1 Antwort
+ 1
You can take more "complex" inputs by simply taking an entire line with std::getline( std::cin, s ); where s is an std::string.
The resulting string, for example your "2+2*2" would then have to be parsed in order to do anything useful with it.
This resource might get you started on that:
https://tomassetti.me/guide-parsing-algorithms-terminology/