3 Input of strings and numbers
This chapter covers
- Input of numbers and strings
- Using
optional
when we may not have a value - Working with random numbers
- Further practice with lambdas and
std::function
In this chapter, we will write a number-guessing game to practice taking inputs by using strings and numbers. We need to generate a random number to guess, accept input from a player, and report whether the player’s guess is correct. We will ensure the guess is actually a number, so we will learn about working with strings and numbers. We will give clues if the guess is wrong, starting with “too big” or “too small,” and then add more clues, such as how many digits are correct. The brief introduction to random numbers will give us a foundation for ...
Get Learn C++ by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.