I have a couple of sentences in an array. I need to randomly display 1 of them. How can I do this?
mrjoli021
-3
Junior Poster
Recommended Answers
Jump to PostLets say you have 5 strings, you need to generate a randome number between 0 and (but not including) 5. Use the mod operator % to accomplish that
int num = rand() % 5;
All 3 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
mrjoli021
-3
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.