How to use C languege to auto generate number???
example:
1001
1002
than 1st number is fit(1002)
by not using this matter:
pls help!!!Code:int id=101;
.........
id++;
Printable View
How to use C languege to auto generate number???
example:
1001
1002
than 1st number is fit(1002)
by not using this matter:
pls help!!!Code:int id=101;
.........
id++;
When you say "auto-generate" I think of random numbers, but it looks like you're talking about incrementing numbers. Can you be a little more specific on exactly what you want?
Absolutely, I don't think that I understand what you said all.
Due to my understand It's my answer:
You can use a large number begin with 1
ex: id = 1000;
And after that you can general other number so that it's less than id
ex: id2 = rand()%id;
And finally you can sum both of them
ex: result = id + id2;
thx i know ald
Code:/* RAND.C: This program seeds the random-number generator
* with the GetTickCount, then displays 10 random integers.
*/
#include <stdlib.h>
#include <stdio.h>
#include <winbase.h>
void main( void )
{
int i;
/* Seed the random-number generator with GetTickCount so that
the numbers will be different every time we run.
*/
srand(
GetTickCount()
);
/* Display 10 numbers. */
for(
i = 0; i < 10;i++
)
printf(
"%6d\n", rand()
);
}
I have no idea what language you're speaking.
you can also to customize generate number :
// Example Usage : generate number between ( 12 ... 102)Code:int
GetRandomNumber(int nLowNumber, int nHighNumber)
{
const int IMax = dwLowNumber;
const int IMin = dwHighNumber;
return (IMin + rand() % (IMax - IMin));
}
// int randnum = GetRandomNumber ( 12, 102 ) ;