If you put the final while() conditional at the beginning of the main() function, and put braces around the rest of the function, it should loop around the whole function:
#include <iostream>
#include <fstream>
#include <windows.h>
#include <string>
using namespace std;
#define DEBUG 0
int Password = -1;
int Option = -1;
char Complete;
string Display;
void pause()
{
#if (DEBUG != 1)
system("pause");
#endif
}
void clearScreen()
{
#if (DEBUG != 1)
system("CLS");
#endif
}
void View_Account() //View All Available Accounts
{
clearScreen();
cout << "--Viewing All Available Resources--\n" << endl;
{
ifstream File ("Log.txt", ifstream::in);
if(File.good())
{
while (!File.eof())
{
getline (File, Display);
cout << Display << endl;
}
File.close();
}
}
cout << "\n\nComplete (Y/N): ";
pause();
}
void Modify_Account() //Modify All Available Accounts
{
cout << "Modify Account";
pause();
}
int main()
{
while (Option != 6)
{
while (Password != 1234)
{
clearScreen();
cout << "Welcome to the MAC Database Search Facility\n" << endl; //Log In Screen
cout << "Please enter your password now: ";
cin >> Password; //User Input
}
clearScreen();
cout << "Welcome ****, please select your option\n" << endl; //Welcome Screen
cout << "1 - View All Accounts" << endl; //All Available Options
cout << "2 - Modify an Account" << endl;
cout << "3 - Delete an Account" << endl;
cout << "4 - Add an Account" << endl;
cout << "5 - Search Accounts" << endl;
cout << "6 - Exit\n" << endl;
cin >> Option;
switch (Option) //Switch Statements
{
case 1:
View_Account();
break;
case 2:
Modify_Account();
break;
}
}
}
Note that I moved the references to system("cls") to a function; this is because it is advisable to comment out the clear screen function while debugging, so you can see the whole screen without it refreshing and losing information. Putting it in a small function like this, and using the DEBUG variable as a sentinel for conditional compilation, you can switch the screen refresh on and off with a single variable.