You can approach this in two ways:
(1) You can generate random numbers until you get one that matches your requirements (no repeated digits). This is easiest to code BUT kind of wasteful in that it might take many number generations to get one usable number.
(2) Generate the digits individually.
First digit randomly one of nine choices (1 - 9)
Second digit randomly one of nine choices (0 - 9, with first digit removed)
Third digit randomly one of eight choices (0 - 9, with first two digits removed)
Fourth digit randomly one of seven choices (0 - 9, with first three digits removed)
To generate a random number between 0 and N inclusive, use "rand() % (N+1)".
You can use "rand() % 9000 + 1000" to generate a random number between 1000 and 9999 if you use the first strategy.
You can use rand() % 9 to generate nine possibilities (0 through 8) which can be used as offsets into an array of valid digit choices if you use the second strategy. (You'd use %8 when there are only 8 choices, and %7 when there are only 7.)
for example:
int i, firstDigit, secondDigit, thirdDigit, digitChoices[9];
/* set up array */
for (i=0; i<9; ++i) digitChices[i] = i+1;
/* pick first digit */
firstDigit = digitChoices[ rand() % 9 ];
/* set up array for second digit */
for (i=0; i<9; ++i) digitChoices[i] = (i >= firstDigit) ? i+1 : i;
/* pick second digit */
secondDigit = digitChoices[ rand() % 9 ];
/* remove second digit from array */
for (int i=0; i<8; ++i)
if (digitChoices[i] >= secondDigit)
digitChoices[i] = digitChoices[i+1];
/* pick third digit */
thirdDigit = digitChoices[ rand() % 8 ];
"I want this number to change through time" just means you generate another one, I think. If you mean something else, you'll have to be more specific.
@M