mini project using codeblock

i have done a bit for my project. my project is about student portal where students can register and log in to check their result over the semester. but i'm having some problems. i was instructed to use structure, function, file processing, array, pointer. the problem is that after i registered as a student, i cannot log in. can someone help me with this problem. btw, im finish the project yet and if you have any idea to add in my project, i would like to hear it. thanks and sorry for my bad english


#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstdlib>

using namespace std;

struct Info
{
string name;
char ic[15]; //identification card no
int matrik;
};

Info student;
Info RegisterStudent();
Info Student_Menu();
void LoginStudent();
void LoginAdmin();

int main()
{
int menu;
do{
cout << "1. REGISTER AS STUDENTS\n";
cout << "2. LOG IN AS STUDENT\n";
cout << "3. LOG IN AS ADMIN\n";
cout << "4. EXIT\n";
cout << "ENTER YOUR CHOICE:";
cin >> menu;
system("CLS");

if(menu==1)
{
RegisterStudent();
}
else if(menu==2)
{
LoginStudent();
}
else if(menu==3)
{
LoginAdmin();
}
else if(menu>4)
{
cout << "YOU ENTER THE WRONG NUMBER\n";
}
}
while(menu!=4);
}

Info RegisterStudent() //for student to register
{
ofstream outStudentInfo("students.dat",ios::out);

if(!outStudentInfo)
{
cerr << "FILE COULD NOT BE OPENED" << endl;
exit(1);
}
cout << "ENTER YOUR NAME:";
cin.ignore();
getline(cin,student.name);
cout << "ENTER YOUR IC NUMBER:";
cin >> student.ic;
cout << "ENTER YOUR MATRIK CARD NUMBER:";
cin >> student.matrik;

outStudentInfo << student.name << "\t";
outStudentInfo << student.ic << "\t";
outStudentInfo << student.matrik << "\n";
system("CLS");
}
void LoginStudent() //in this function, user will enter the id and password to log in
{
int id,x;
char passstudent[15];
cout << "ENTER YOUR ID(MATRIK NO.):";
cin >> id;
cout << "ENTER YOUR PASSWORD(IC):";
cin >> passstudent;

while(id!=student.matrik || passstudent!=student.ic)
{
if(id==student.matrik && passstudent==student.ic)
{
Student_Menu();
}
else
cout << "YOU ENTERED WRONG ID OR PASSWORD" << endl;
system("PAUSE");
system("CLS");

cout << "PLEASE RE-ENTER YOUR ID(MATRIK NO.):";
cin >> id;
cout << "PLEASE RE-ENTER YOUR PASSWORD:";
cin >> passstudent;
}
}


void LoginAdmin()
{
string idadmin;
string passadmin;
cout << "ENTER YOUR ID:";
cin.ignore();
getline(cin, idadmin);
cout << "ENTER YOUR PASSWORD:";
cin.ignore();
getline(cin, passadmin);
system("CLS");
}
Info Student_Menu()
{
cout << "1. DISPLAY RESULT";
cout << "2. DISPLAY ALL RESULT";
}
Topic archived. No new replies allowed.