My previous step hs been resolved.
Now it's on to the next component.
As previously stated, I am using a do-while loop with a switch-case.
I've figured out how to state the functions that I'm calling to, and it now allows me past the main menu.
Once I'm in however, it will not allow me back out to the main menu.
For those who've not read my earlier posts, this whole thing worked exactly as expected in VS 6 C++, and Borland's C++ back when I'd first written it in 1999 (with Borland), and 2001(with VS6 C++). It wasn't until the change from Fat32 to NTFS that it failed to operate any longer. I figured that enough had changed that I'd need to do something differently than before.
So, I recently came here to figure out how to get it to work again. Little was I aware at the time that C++ layout has changed just enough that I'm learning all over again how it operates.
So much for the history, now on to my present issue-- not being able to return to the main menu.
Previously, I'd set a do {.......} while (ch != 27) as my escape back to the main menu. It worked great before, but now something is different, and I'm not sure where to go to find how it needs to be resolved.
As recommended by Ancient Dragon, I'm running MS Visual Studio Express 2008 C++. I've looked through the help file, and have only been able to identify exit() as a viable escape, but that is not working.
I've just tried exit(0); that did not work.
So, bear with me while I explain my steps.
A- I have 3 choices to get into my functions.

  1. MainMenu explaining access, and exit points.
  2. Choice1
  3. Choice2
  4. Choice3

B- I have one choice to exit the program before I activate my other 3 choices.

# include "stdafx.h"
# include <iostream>
# include <cmath>
# include <xutility>
# include <stdlib.h>
# include <cctype>
# include <conio.h>
# define PI 3.1415926535898

int n;
int ParA, ParB, ParC, ParD, ParE; 

using namespace std;

int functionA (int& ParA, int& ParB, int& ParC, int& ParD) 
//ParA through ParE are parameters/variables (please pardon me if I 
//incorrectly stated the terms) within my functions. 
{
secondary menu to explain how to use this function-A.
do
   {
     core code for this function.
   } while (ch_n != 27);
//return n; //where n is an equation within the core code.
exit(0);
}
int functionB (int& ParA, int& ParB, int& ParC, int& ParD, int& ParE);

secondary menu to explain how to use this function-B.
do
   {
     core code for this function.
   } while (ch_(n+1) != 27); 
//the "ch_(n+1) is a character subscript I used for my while escape.

//return n; //where n is an equation within the core code.

exit(0);
}
int functionC (int& ParA, int& ParB);

secondary menu to explain how to use this function-C.
do
   {
     core code for this function.
   } while (ch_(n+2) != 27);
//return n; //where n is an equation within the core code.
exit(0);
}

int main()
{
Do
{
   main welcome menu which gives options to access my functions, 
   or exit the program. 

   Switch(ch)
      {
        case '1' : functionA(ParA, ParB, ParC, ParD);
          break;
        case '2' : functionB(ParA, ParB, ParC, ParD, ParE);
          break;
        case '3' : functionC(ParA, ParB);
          break;
        default : exit(0);
      } 
 } while (ch != 27);
}

However, once inside my functions, I only have a return for my exit. I have looked around the web, via google, and cannot locate anything other than exit(0); , or return 0; to end a function.
I've now commented the return, and placed exit(0), as well as exit(1) in it, and it does not allow me an exit, without manually terminating the program console window.

How does one call an exit, or escape key within a function with this new C++?

(And when I say "new" I'm just saying that it's not the same C++ I used 7 to 9 years ago, so please don't go ballistic on me. Not everything is different, but enough is to start me out again, virtually from scratch.)
Thank you for your helps.
Best.

As you must have found out, the exit(0) function exits the entire program, not just the function in which it appears.

It would appear you have the wrong notion about how to return from a function in C or C++

int foo1()
// This function will return the value of an integer
{
    // do something

    // now return the integer
    return 1;
}

// or to exit a function that has no return value
void foo2()
{
    // do something

    return;  // this line is optional.  It can be omitted in void functions
}

int main()
{
     // get the return value from a function that returns an integer, such as foo1()

     int retvalue = foo1();

     // call a void function
     foo2();
}

Its not possible in standarc c++ to capture the <Esc> key. You have to use something nonstandard such as functions in conio.h, if your compiler supports it.

Ancient D,
Yes, I have found that out. :-/

As you must have found out, the exit(0) function exits the entire program, not just the function in which it appears.

It would appear you have the wrong notion about how to return from a function in C or C++

You surmise correctly.... I have plenty of wrong notions about C++. More so now than I'd thought I had before. :?: I barely eeeked though my two runs through C++ at college. Strike it up to playing with tonka trucks as a child, back when computers were the size of your typical house. Programs were punch cards, and my dad bought home one of the very first IC chips when I was 7. It looked to me like a black, plastic caterpillar. In fact, the original Star Trek came out that year.

int foo1()
// This function will return the value of an integer
{
    // do something

    // now return the integer
    return 1;
}

// or to exit a function that has no return value
void foo2()
{
    // do something

    return;  // this line is optional.  It can be omitted in void functions
}

int main()
{
     // get the return value from a function that returns an integer, such as foo1()

     int retvalue = foo1();

     // call a void function
     foo2();
}

Its not possible in standarc c++ to capture the <Esc> key. You have to use something nonstandard such as functions in conio.h, if your compiler supports it.

The only way I've found that out is by a lack of information on the issue. It did in VS6, and Borland's C++. And if you look back at my post, I actually do have #include <conio.h> in there. :confused:

Be a part of the DaniWeb community

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