Hi everyone! I`m new here in daniweb.
Our Prof. want us to make a game w/ a menu.
I already made the game but my main menu is the problem.
how to make a menu that after the game it will ask.
Do you want to try again >>> then will go back to menu?

Recommended Answers

All 2 Replies

Sure.one way to do it is, put the whole program in an infinite loop and ask the user each time whether to continue or not. Check the user's answer
if yes loop back
else end the loop and exit.

Here's one possible implementation of diwakar's algorithm:

#include <ctype.h>
#include <stdio.h>

int is_finished(void)
    char line[BUFSIZ];
    fputs("Again? (y/n): ", stdout);
    return fgets(line, sizeof line, stdin) == NULL
        || toupper(line[0]) != 'Y';

int main(void)
    do {
        puts("Doing stuff...");
    } while (!is_finished());
    return 0;
Be a part of the DaniWeb community

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