954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Clear All Variable Values

Hi. I have a program that goes a little like this:

// Include files, etc...

int main()

//code...


if (input == "logout");
{
    return main();
}


// rest of the code


Now, every time the program goes to main, the values previously stored in the varibles are still there. I am looking for a way to start with a clean slate and wipe all of the variables.

cppnewb
Junior Poster in Training
52 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

Just reset the variables to an empty string

input = "";

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

You probably shouldn't be "going to main". Remove the return main(); part and change it to a loop.

nucleon
Posting Pro in Training
478 posts since Oct 2008
Reputation Points: 163
Solved Threads: 91
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You