Sign in to follow this  

help in C

This topic is 3665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im trying to make the game who wants to be a millionair in C Im trying to get the program to scan a question randomly from a txt file from this and have the user answer the question and if it is correct the user continues the game until 5 of the 10 questions are correct and continues to the next group of questions in another txt file. i havent done anything before is trying to scan whole question at random, so my question is how is that done? Thanks (here is a sample of my first group of questions in a txt file) 1.In the United States, how much is a dime worth? (1) 25 cents (2) $1,000,000 (3) 5 cents (4) 10 cents 2.In which country was George Washington the first president? (1) Philippines (2) What? Who's George Washington? (3) Canada (4) United States of America 3.How many inches are in a foot? (1) 13 (2) 12 (3) 6 (4) 10 4.Michael Jordan professionally played which of these sports? (1) Luge (2) Cricket (3) Basketball (4) Water polo 5.What was the maiden name of Bill Clinton's wife? (1) Frances Folsom (2) Barbara Pierce (3) Monica Lewinsky (4) Hillary Rodham 6.Dr. Seuss wrote all of these books except for which? (1) 'Green Eggs and Ham' (2) 'Oh, the Places You'll Go!' (3) 'Tootle' (4) 'The Cat in the Hat' 7.In the 'Garfield' comic strip, what is the name of Garfield's rubber chicken? (1) Herbie (2) Pooky (3) Stretch (4) Ed 8.The act of having several wives at one time is called what? (1) Polygamy (2) Monogamy (3) Apogamy (4) Endogamy 9.What was the first U.S. state to enter the Union? (1) New Jersey (2) Georgia (3) Pennsylvania (4) Delaware 10.What is the name of the angel in 'It's a Wonderful Life'? (1) Clarence (2) Yvonne (3) Hilda (4) Bernard

Share this post


Link to post
Share on other sites
It is possible to jump to random points in a file, but in your case it would be far easier to initially read the entire textfile in one go and store it in some intermediate representation in memory. Once you have all of the questions in some sort of list or dictionary, choosing questions randomly is almost trivial (certainly easier than trying to randomly read in from a textfile).

Share this post


Link to post
Share on other sites

This topic is 3665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this