generating random values in iPhone

前端 未结 6 927
Happy的楠姐
Happy的楠姐 2020-12-20 00:18

I have used rand(). But it gives a specific value even after I restart application.

I have implemented following in my application.

- (void)viewDidLo         


        
6条回答
  •  轮回少年
    2020-12-20 01:18

    Since you are using random() and not rand() you should seed the random generator with this bit of code...

    srandomdev();

提交回复
热议问题