me too, can someone teach me how to do it,, or just give me a simple example,so that a beginner like me will understand it most..help me experts plss..im new to c++
void userInput(char* checkInput);
int main()
{
bool correctInput = false;
char input[80];
userInput(input);
correctInput = braceCheck(input);
if(correctInput == true){
cout<<"CORRECT!"<<endl;
main();
}
else{
cout<<"INCORRECT!"<<endl;
main();
}
}//end main
void userInput(char* checkInput)
{
cout<<"Input Anything: ";
cin>>checkInput;
if((checkInput[0]=='e')&&(checkInput[1]=='x')&&(checkInput[2]=='i')&&(checkInput[3]=='t')){
exit (0); //terminates the program
}//end if
}//end userInput function
//........
-----------------------
but what will I do if I want the code to return to userInput() function again?
If I use userInput(input) instead of main() it will only recurse 1 time.
so what is the best solution for this? thx
You just don't know what will happen (since K&R just assumed that no one in their right mind would ever recurse on main). Hence, the C++ standards committee decided to address the issue and expressly forbid it.