Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Random number generator acting strange...?

$
0
0
Ok, so here is my program:

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream>
#include <ctime>

int main()
{
int number;
srand((unsigned)time(0));
printf("NAME SURNAME\n");
number = 100000000 + rand() % 999999999;
printf("%d", number);

getch();
return (0);
}

This produces a random 9 digit number, which I want, but seems to go up by 1 ever second or something? I am after completely random! like 111111111 the first try and 534567648 the second try, but it is like 100000564 the first try then do it right away again and it is 100000572 and so on and so forth. I have scowered the internet trying to find helpful guides to random number generators and nothing has come up.

I was unable to use mt_rand(), which sounded like it could give me what I want, but it kept saying it was not identified and I couldn't find whatever library was needed for it...? I am on visual studios 2010 if that makes any difference...

Thanks for any help!

Sorry! Ah! I don't know what happened haha so do please forgive the double post. Something went crazy.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>