-
February 23rd, 2004, 05:15 AM
#1
Random numbers
hi!
I am using the following code to generate a random string. But each time i get the same string output. Can anyone help.
char myarray[22];
char* CGeneratorApp::GenerateString()
{
myarray[21]='\0';
for(int k=0;k<21;k++)
{
myarray[k] = (char)(((int)rand()%25)+65);
}
char first[2];
intUsed++;
sprintf(first,"%d",intUsed);
if(intUsed<10)
{
first[1]=first[0];
first[0]='0';
}
first[0]=(char)((int)first[0]+27);
first[1]=(char)((int)first[1]+27);
myarray[8]=first[0];
myarray[10]=first[1];
AfxMessageBox(myarray);
return myarray;
}
Thnx in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|