I want to print strings randomly

Asked 2 years ago, Updated 2 years ago, 22 views

There are many strings

When I print it out like this, I want to press refresh number 6, and I want to make a random string, so what function should I use? It's an example from a book, but I can't solve this TT

c++

2022-09-20 21:46

1 Answers

Run the rand() function to obtain a random value.
Usually, before you use the rand() function, you run a function that sets a seed value called srand(), but if you search for the rand() function, you'll find many examples.
You can pre-declare multiple strings as a string array, get random numbers, index the array, and get the string.
http://www.cplusplus.com/reference/cstdlib/rand/


2022-09-20 21:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.