Code:
#include <iostream>
#include <fstream>
#include <windows.h>
#include <mmsystem.h>
#include <tchar.h>
/* I know this is horribly written but it is an example */
using namespace std;
ULONG GetSongLength(LPCTSTR szFile);
int age(int t_val, string temp);
int display(int t_val, string temp);
bool Exit = false;
int main(int t_val, string temp) {
if ( Exit == false ) {
cout << "Enter your age: ";
cin >> t_val;
cin.ignore();
temp = "";
age(t_val, temp);
}
return 0;
}
int age(int t_val,string temp) {
cout << "Okay enter your name: ";
getline (cin, temp);
cin.ignore();
display(t_val, temp);
cout << "SEE IT DOESNT EXIT IT RETURNS HERE" << endl;
cin.get(); //after this it returns to main thus exiting, but it returns to calling function, so therefor
//exiting the program in this way does not work
}
int display(int t_val, string temp) {
cout << "The age you entered: " << t_val << endl;
cout << "The name you entered: " << temp << endl;
Exit = true;
cin.get();
main(t_val, temp);
}
I hope that works for an example