Function for game rules

Hello, I am currently taking C++ (1st half) in college and we are to write the Hi/Lo guessing game. My teacher wants us to have the main function call upon user defined functions that run the different parts of the game (i.e one to display the rules, one to pick the mystery number, etc). I'm having trouble on how to go about writing a function that displays the rules. Here is my function...thingy (forgot what it's called):

[function-type] rules (void)

I thought about seeing how to setup arrays, but we haven't gotten to arrays (just briefed over them) and we're not allowed to use what we haven't learned. I don't want someone to just give me the answer, just lead me in the right direction.

If it helps, we're using C++ Programming by D.S. Malik 7th Ed and we're only in Ch 6.

Thanks in advance for the help, and let me know if you need more info.
I think the word you are looking for is "prototype."

I'm having trouble on how to go about writing a function that displays the rules.


What exactly are you having trouble with? Defining the function? Writing the function body? Printing the rules?
That's it thank you!

A little of all. I know how to define it, just not sure what type to put.
For the body, I know how to set a function body, but I'm not sure if I use strings and return the set of strings or tell it to just display all the rules and when the player hits enter clear the screen and return to the main function. If the later is the best option, how do I tell it to return nothing?
OH I FORGOT!

I wanted to also include the option for the player to set the min & max, and if they don't set it then it defaults to 0-10. If I could get some help with that too, please?
The return type should be void because it doesn't need to return anything. Just have it print the rules to cout:
1
2
3
4
void rules(void)
{
   // code to print out the rules
}

Awesome thanks!! The first void is where I was lost mostly. After that it was a matter of what's best.

If I wanted to allow the player to set the min & max on the same "screen" as the rules, would I do it in this function, or in the main function? I do have a function setup to create a random number between the min & max the player sets.

Sorry if that's confusing, it's been a long day and I'm tired. :-)
No problem. I would set the min and max inside setup() or maybe even a third function. That functionality has more to do with setting up the game than with showing the rules. In particular, a user might want to see the rules again part way through the game. I'm not suggesting that you add this functionality, just pointing out the thinking behind the design.
ok. Thank you so much for your help!!
Pet peeve:

void rules(void)

Do this instead:

void rules()

Putting void in an empty argument list is a weird C thing and is totally unnecessary in C++.
Topic archived. No new replies allowed.