You need to generate a rand number in the range of the ASCII character set, then convert that number into a letter. Repeat for the required number of characters.
(A-Z = 65 - 90, a-7 = 97 - 122)
i.e.
for 1 letter,
Generate number between 0 & 57
Add 65 to that number
if number is > 90 and < 97, discard
char x = number;
For a string, do as above, but you need a counter into the char array i.e.
char x[10];
for (i = 0;i<10;i++)
{
Generate number between 0 & 57
Add 65 to that number
if number is > 90 and < 97, discard
x = number;
}
apologies for posting mostly text, but I am sure you get the idea.
Kalisto, thank you for the help. I am doing data structures and doing a program that is a two player black jack game. I am going to make the string a char set and will relate the number generated correspond to the character. Rich
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.