Declare the ifstream outside of either Password() or ConfirmCode() and pass it to both functions as a parameter by reference. That way the stream will remain open and the pointer that reads the file will remain in place between function calls.
where Password() and ConfirmCode() are declared with a reference to an ifstream object as a parameter like this:Code:ifstream fin("sample.txt"); if(!fin) cerr << "unable to open file" << endl; int x; x = Password(fin); if(x == 1) ConfirmCode(fin);
int Password(ifstream &);
When you're done pass fin around, you can close it.