tags:

views:

51

answers:

2

I am to create a c++ logic game with with the difficulty of 3-10 characters (@#%?) that are produced within a string randomly. The player is to guess the random characters. Once the player has guessed, the message of how many the player guessed right is displayed. I am using the switch command to have the player determine the difficulty level, I am not sure how to create a random string with gen_random.

A: 

This was answered here on stack overflow:

http://stackoverflow.com/questions/440133/how-do-i-create-a-random-alpha-numeric-string-in-c

This guys solution generates a random string of characters (i.e. char*) of a specified length.

C Johnson
A: 

This sounds like homework. But remember that a character is just a number you can get a random number using rand. So char x = 'a' + aRandomNumber()

rerun