我这边试了没问题啊,主要就是要有#include<time.h>,不然你试试下面这个写法?
#include<time.h> time_t now; srand((unsigned)time(&now));