(C) back or continue

From: Paul Fedorenko (pfedorenko_at_look.ca)
Date: 10/28/04


Date: Thu, 28 Oct 2004 00:11:56 -0400

A friend of mine asked me to write a text-based "game" for him as part of a
psyche experiment that he's going to be conducting. The first few screens
of the program are supposed to display the instructions for gameplay, and
consist of a lot of printf() statements.

What I'm trying to do is figure out a way of allowing the user to go back a
screen to double-check instructions if they missed something, then continue
on to the next screen. I've written the program so that each screen of
instructions lives in it's own function, and going back a screen is simply a
matter of calling the function that came before...

Like this, I guess:

void screen_2(void)
  {
    printf("Press <Enter> to continue or <b> to go back. ");
    getchar(option);
    // or possibly scanf("%c", &option);
    if (option = 'b')
         screen_1(); // goes back to previous screen
    else
         // expression to return to main() so next function can be run
  }
The problem, as you can see, is trying to figure out what comes after that
else. I've tried a "return 0;" but that causes the program exit to the last
couple of lines of main(); and skipping what I want it to do altogether.

Here's a sample of what I have in main(); just for reference:

void screen_2(void);
int main(void)
{
    char again;

     do
     {
        screen_1();
        screen_2();
        printf("\n\nPlay again (Y/N)? ");
        scanf("%c", &again);
    }
    while(again != 'N' && again != 'n');
    // system("cls");
    printf("Thank you for playing.");
    return 0;
}

I'm going to keep working on it, and the rest of the program (have to build
an array, and set up some file I/O), and I'll check back here tomorrow or
something.



Relevant Pages

  • Re: (C) back or continue
    ... > psyche experiment that he's going to be conducting. ... The first few screens ... It might be a better idea to keep instructions in a file and read from that. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: PowerPoint Notes
    ... Follow the instructions you found for presenter view - that's excatly what ... MOS Master Instructor ... the same on both screens or if I can have my notes visible for just me at ...
    (microsoft.public.powerpoint)
  • File Protection
    ... I have followed the instructions on the help ... screens for changing permissions but every file I create ... >as administrator on the new system? ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Outlook wont send messages?
    ... missed something it's screens were totally different than the instructions. ... One other thing I noticed is that when outlook is trying to ... Not sure what these items are, could be from the old mail account? ...
    (microsoft.public.outlook.installation)
  • Re: Katz Eye focusing screen
    ... screens and I am back to "0" compensation. ... asking for more detail on the instructions. ... link to a pdf file detailing the instruction. ... I have decided the installation is well within my capabilities. ...
    (rec.photo.digital.slr-systems)