谁可以帮我详细的解释一下c语言里函数rand()和srand()的用法

新手不太明白.通俗点的.

srand是用来设置随机时间的种子,一般与rand()结合使用。否则直接用rand()的话,每次运行程序的结果都相同。
原型:int srand (unsigned int seed);
srand((unsigned) time(&t));此句的参数使用time()函数获得系统时间作为种子,并且把获得的时间强制转换为unsigned。
温馨提示:答案为网友推荐,仅供参考
相似回答