i have to create a game using c++ language n i want to create something new...so i decide to create a games name "don't forget the lyric" which is the user need to fill in the blank on the lyric given. so, my question is how can i random the blank in the lyric to make the user will get new question if they choose the same song.

One way of doing it would be to use a 2 dimensional array of strings. For example:

// Array that will hold 10 different lyrics, up to 20 words per set
string lyrics[10][20];

Now say that song number 4 is chosen and you want to randomize which word is blanked out.

// This variable will hold the randomly generated index
int randIndex = rand() % 20;  // 0 - 19

// Add code here to use the random index to replace that word with an empty string in your output

ok thanks..i will try...

i have one more question... if in one category have 5 song how can i randomly display 2 song from that 5 song...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.