[comp.lang.c] Looping Conditions

curt@cieunix.rpi.edu (Curt Signorino) (06/16/88)

I have the following in my menu-oriented code:

  while ((wacky=get_option("  PHONE SYSTEM  ")) != 0) {
    switch (wacky) {
      case '1':
                .
		.
		.
		while ((hard_option=get_option("    HARDCOPY    ")) != 0) { 
		  switch (hard_option) {
		    case '1':
				.
				.
				.

	The function get_option() displays a menu with the heading
in quotes and returns the number of the option picked.  One of the 
options of the first menu ("PHONE SYSTEM") is to branch to the 
second menu ("HARDCOPY").  To exit a menu, the user presses ESC.
In addition, if the user is in the root menu and hits ESC, he/she'll
be kicked out into the operating system (4.3 BSD UNIX).

	What I'd obviously like is for ESC in a child menu to just
kick the user back to the parent menu.  Unfortunately, hitting ESC in
the child causes the user to be kicked out of the root menu, too, 
which is definitely not what I want.

	I have a feeling the problem is something to do with how I
have the conditionals in the while statements.  I'm a bit new to C
and any help would be appreciated.  Please don't assume I know what
I'm doing!

Thanks in advance.

Curtis S. Signorino                     ,,,,,,        curt@cieunix.rpi.edu
Center for Integrated Electronics        _  _       ...!itsgw!cieunix!curt
RPI                                    C   > /  
                                        \  o