In the program below what is the difference between rand and srand? My book says that rand returns an int between 0 and RAND_MAX, which is never smaller than 32,767. Yet this code returns a number from 1-6, how is that? I see the line ( rand() % 6 ) + 1
but I don't see how that would give a number from 1-6.
lewashby 56 Junior Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Moschops 683 Practically a Master Poster Featured Poster
L7Sqr 227 Practically a Master Poster
Rashakil Fol 978 Super Senior Demiposter Team Colleague
deceptikon 1,790 Code Sniper 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.