My assignment is to program a room booking system that has different restrictions for different users. So far i'm done with the login pages when i noticed something wrong. The program works fine when i enter numbers but gets stuck when i enter a character. There's also supposed to be 3 text files containing the names of the users which i can't include here. I think you'll notice those . By the way, i'm very much a newbie to c++. I think you'll notice that too... Here's a sample of my source code.

#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;

//-------------------------------------------------------------------------------------------------------------------------------
// Function Prototypes and declarations
//-------------------------------------------------------------------------------------------------------------------------------
ifstream inputFromFile;
ofstream outputToFile;

void loginChoice();
void administratorLogin();
void memberChoice();
void lecturerLogin();
void studentLogin();
void administratorMenu();
void lecturerMenu();
void studentMenu();

//-------------------------------------------------------------------------------------------------------------------------------
// Function to open and write a file
//-------------------------------------------------------------------------------------------------------------------------------
void openWriteFile(const string filename)
{
outputToFile.clear();
outputToFile.open(filename.c_str(),ios::in);
if (!outputToFile)
cout << "There was an error opening the file" << endl;
}

//-------------------------------------------------------------------------------------------------------------------------------
// Function to close a written file
//-------------------------------------------------------------------------------------------------------------------------------
void closeWriteFile()
{
outputToFile.close();
}

//-------------------------------------------------------------------------------------------------------------------------------
// Function to open and read a file
//-------------------------------------------------------------------------------------------------------------------------------
int openReadFile(const string filename)
{
inputFromFile.clear();
inputFromFile.open(filename.c_str(),ios::in);
if (!inputFromFile)
cout << "There was an error opening the file" << endl;
}

//-------------------------------------------------------------------------------------------------------------------------------
// Function to close a read file
//-------------------------------------------------------------------------------------------------------------------------------
int closeReadFile()
{
inputFromFile.close();
}

//-------------------------------------------------------------------------------------------------------------------------------
// The Main Function
//-------------------------------------------------------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
loginChoice();
return 0;
}

//-------------------------------------------------------------------------------------------------------------------------------
// Login Choice
//-------------------------------------------------------------------------------------------------------------------------------
void loginChoice()
{
int choice;

cout <<" ||------------------------------||"<<endl;
cout <<" ||Multimedia Room Booking System||"<<endl;
cout <<" ||------------------------------||"<<endl;
cout <<" || Please choose: ||"<<endl;
cout <<" || ||"<<endl;
cout <<" || '1' for administrators ||"<<endl;
cout <<" || '2' for members ||"<<endl;
cout <<" || '3' to exit program ||"<<endl;
cout <<" ||------------------------------||"<<endl<<endl<<endl;

cout << "Your choice is: ";
cin >> choice ;

if (choice == 1)
{
system ("cls");
administratorLogin();
}
else if (choice == 2)
{
system ("cls");
memberChoice();
}
else if (choice == 3)
{
// will exit
}
else
{
cout <<endl<<"Please choose from the list above"<<endl;
system ("PAUSE");
system ("cls");
loginChoice();
}
}

//-------------------------------------------------------------------------------------------------------------------------------
// Administrator Login
//-------------------------------------------------------------------------------------------------------------------------------
void administratorLogin()
{
int a, ID_number = 0;
string password, b;

cout<<" ID number : ";
cin>>ID_number;
cout<<" | "<<endl;
cout<<" Password : ";
cin>>password;
system("cls");

openReadFile("AdministratorPassword.txt");
while(!inputFromFile.eof())
{
inputFromFile>>a>>b;
if(!inputFromFile.fail())
{
if((a==ID_number)&&(b==password))
{
closeReadFile();
administratorMenu();
}
}
}
if((a!=ID_number)||(b!=password))
{
cout<<"Your ID number or password is invalid "<<endl;
closeReadFile();
system ("PAUSE");
system ("cls");
loginChoice();
}
}

//-------------------------------------------------------------------------------------------------------------------------------
// Administrator Menu
//-------------------------------------------------------------------------------------------------------------------------------
void administratorMenu()
{
cout <<"there will be a menu here";
system ("PAUSE");
system ("cls");
loginChoice();
}


//-------------------------------------------------------------------------------------------------------------------------------
// Member Type Choice
//-------------------------------------------------------------------------------------------------------------------------------
void memberChoice()
{
int choice;

cout <<" ||------------------------------||"<<endl;
cout <<" || Members Login ||"<<endl;
cout <<" ||------------------------------||"<<endl;
cout <<" || Please press: ||"<<endl;
cout <<" || ||"<<endl;
cout <<" || '1' for lecturers ||"<<endl;
cout <<" || '2' for students ||"<<endl;
cout <<" || '3' back to first menu ||"<<endl;
cout <<" || '4' to exit program ||"<<endl;
cout <<" ||------------------------------||"<<endl<<endl<<endl;

cout << "Your choice is: ";
cin >> choice ;

if (choice == 1)
{
system("cls");
lecturerLogin();
}
else if (choice == 2)
{
system("cls");
studentLogin();
}
else if (choice == 3)
{
system("cls");
loginChoice();
}
else if (choice == 4)
{
//will exit
}
else
{
cout <<endl<<"Please choose from the list above"<<endl;
system ("PAUSE");
system ("cls");
memberChoice();
}
}

//-------------------------------------------------------------------------------------------------------------------------------
// Lecturer Login
//-------------------------------------------------------------------------------------------------------------------------------
void lecturerLogin()
{
int a, ID_number = 0;
string password, b;

cout<<" ID number : ";
cin>>ID_number;
cout<<" | "<<endl;
cout<<" Password : ";
cin>>password;
system("cls");

openReadFile("LecturerPassword.txt");
while(!inputFromFile.eof())
{
inputFromFile>>a>>b;
if(!inputFromFile.fail())
{
if((a==ID_number)&&(b==password))
{
closeReadFile();
lecturerMenu();
}
}
}
if((a!=ID_number)||(b!=password))
{
cout<<"Your ID number or password is invalid "<<endl;
closeReadFile();
system ("PAUSE");
system ("cls");
memberChoice();
}
}

//-------------------------------------------------------------------------------------------------------------------------------
// Lecturer Menu
//-------------------------------------------------------------------------------------------------------------------------------
void lecturerMenu()
{
cout <<"there will be a menu here";
system ("PAUSE");
system ("cls");
memberChoice();
}

//-------------------------------------------------------------------------------------------------------------------------------
// Student Login
//-------------------------------------------------------------------------------------------------------------------------------
void studentLogin()
{
int a, ID_number = 0;
string password, b;

cout<<" ID number : ";
cin>>ID_number;
cout<<" | "<<endl;
cout<<" Password : ";
cin>>password;
system("cls");

openReadFile("StudentPassword.txt");
while(!inputFromFile.eof())
{
inputFromFile>>a>>b;
if(!inputFromFile.fail())
{
if((a==ID_number)&&(b==password))
{
closeReadFile();
studentMenu();
}
}
}
if((a!=ID_number)||(b!=password))
{
cout<<"Your ID number or password is invalid "<<endl;
closeReadFile();
system ("PAUSE");
system ("cls");
memberChoice();
}
}

//-------------------------------------------------------------------------------------------------------------------------------
// Student Menu
//-------------------------------------------------------------------------------------------------------------------------------
void studentMenu()
{
cout <<"there will be a menu here";
system ("PAUSE");
system ("cls");
memberChoice();
}











Man, i dont even know how to use this message board properly.