Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
>>Extract the lower 4 digits of the result produced by step 2.
The easy way is to convert the number to a string then only use the last 4 digits.
int num = 12347;
char buf[10];
sprintf(buf,"%d",num);
int seed = atoi( &buf[1] );
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>Extract the lower 4 digits of the result produced by step 2.
The easy way is to convert the number to a string then only use the last 4 digits.
int num = 12347;
char buf[10];
sprintf(buf,"%d",num);
int seed = atoi( &buf[1] );
The easier way is to divide by 10000 and take the remainder
int seed = num % 10000 ;
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287
The easier way is to divide by 10000 and take the remainder
int seed = num % 10000 ;
OMG Yes that is a lot easier :*
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343