I am using function random()%x for the generation of a random number, but every time I start the application I see that it creates or generates the same number.
Lik
You'll likely have better luck with arc4random(), you don't need to explicitly seed it and it seems to be a "better" random.
arc4random()
Call srandomdev() first.
srandomdev(); long my_rand = random();