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.
- MainMenu explaining access, and exit points.
- Choice1
- Choice2
- 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.