This is our new and revised program...
for the registration:
I thank all of those people who helped me.
for the search function:
so I've manage to, actually my teammate managed to get a search function working
for edit function:
we havent figured it out on what methods are gonna be used to properly edit a certain student..
for instance i want to edit the information of student (insert student ID here),
first we'll prompt the user to enter the student Id as written above,
then after finding the record we would then allow us to manipulate student (x)'s
personal information which is only the first, middle, and last name
can someone guide us?

#include <iostream>
#include <string>
#include <fstream>
#include <cctype>
#include <Windows.h>
using namespace std;

struct Record
{
	string FName, LName, MName, Email, Address, Bday, Program, ConNum;
	int StudNum,  Year;
};


//Declaration for the struct.
Record Students[50];
//The User-Defined Functions.
void Reg(Record Students[]);
void bubbleSort(Record Students[],int length);
void print(Record Students[]);
void search(Record Students[]);
//void edit(Record Students[]);
//Global Declaration of variables;
string CHOICE;
int studInt;
int length=0;
char response;
int z=0;
//Declaration for the registration function.
//int i=0; dahil nag initialize sa case 1..at student number error
//Declaration for the search function.
string LastName,FirstName, MiddleName;
int NumInFile; 
//Main program.
int main()
{
	bool found=false;
	char choice;
	do
	{
	//The user will choose what to do.
	cout<<"********************************************************\n"
		<<"*********************STUDENT RECORD*********************\n"
		<<"********************************************************\n"
		<<" [1] => Registration.\n"                    
		//Will go to reg()
		<<" [2] => Search the student record.\n"
		//Will go to search();
		<<" [3] => Quit.\n";
	cin.get(choice);
	
	if (getline(cin, CHOICE)) // To delete the other unnecesary letters.
		;
	switch(choice)
	{
	case '1':
		{
		Reg(Students);
		break;
		}
	case '2':
		{
		system("CLS");
		search(Students); //Students because we have declared that as a identifier of the struct.
		break;
		}
	case '3':
		{
			exit(0);
		}
	default:
		{
			cout<<"your choice is not on the list"<<endl;
			system("CLS");
			return main();
		}
		break;
	} 
	bubbleSort(Students,length);// This will sort the names of the students.
	print (Students);
	cout<<"Want another transaction? (Y/N) ";

	cin>>choice;
	//cin.ignore();
	toupper(choice);
	if (toupper(choice)=='Y')
	{
		system("CLS");
		continue;
	}
	found=true;
	}
	while (!found);
	return 0;
}




void Reg(Record Students[]) // This Function Will Register a student to the group.
{
     int i=0;//where i serves as an index
	//bool found=false;//will be used for loops later on(will be deleted if we find this useless lateron)
	ofstream outFile;
	ifstream inFile;
	//We declare as an output file the outFile.
	outFile.open("records.txt", ios::app); //We open.
	inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/MP 2/MP 2/records.txt");
	

	//LOAD FUNCTION
	while (!inFile.eof())
	{
		char check;
		check=inFile.peek();
		if (!isdigit(check))
		{
			cout<<"We have found an available slot for you!!"<<endl;
			break;
		}
		system("CLS");
		inFile>>Students[i].StudNum ;
		inFile.ignore(10, '\n');
		inFile>>Students[i].FName;
		inFile.ignore(10, '\n');
		inFile>>Students[i].MName;
		inFile.ignore(10,'\n');
		inFile >> Students[i].LName;
		inFile.ignore(10,'\n');
		cout<<"CHECKING FOR AVAILABLE SLOTS...\n\n"
			<<"Student already registered in slot "<<i+1<<"\n"
			<<"Looking for available slots\n"
			<<"Please wait for a few momments....\n";;
		i++;
		Sleep(700);
	}
	while (i<50)
	{
		system("CLS");
		cout<<"********************************************************\n"
			<<"Student's registration form:\n"
			<<"********************************************************\n\n"
			<<"You are on slot "<<i+1<<endl<<endl;

		Students[i].StudNum=2010+i; 
		outFile<<Students[i].StudNum<<endl;
		
		cout<<"Enter your First Name: "<<flush;
		getline(cin,Students[i].FName);
		outFile<<Students[i].FName<<endl;

		cout<<"Enter your Middle Name: ";
		getline(cin,Students[i].MName);
		outFile<<Students[i].MName<<endl;


		cout<<"Enter your Last Name: ";
		getline(cin,Students[i].LName);
		outFile<<Students[i].LName<<endl;
	

		cout<<"Your student number is: "<<Students[i].StudNum<<endl;
		i++;
		cout<<"Register another student? (y/n)";
		cin>>response;
		if (response=='y' || response=='Y')
		{
			
			length+=1;
			cin.ignore();//allows you to further add students... if taken out, program would bug you... bring RAID
			system("cls");
			continue;
		}
		else
		{
			length+=1;
			break;
		}
	}
}
void bubbleSort(Record Student[],int length)
{
	string temp1;
	int iteration;
	int index;
	for (iteration=1; iteration<length; iteration++)
	{
		for (index = 0; index<length-iteration;index++)
		{
			if ((Students[index].LName)>=(Students[index+1].LName))
			{
				temp1=Students[index].LName;
				Students[index].LName=Students[index+1].LName;
				Students[index+1].LName=temp1;
			}
			

		}
	}
}




void print(Record Students[])
//This function will print the values in the struct Students[]
{
	system("cls");//This will clear the screen.
	cout<<"********************************************************\n"
		<<"*********************STUDENT RECORD*********************\n"
		<<"********************************************************\n";
	/*for (int x=0; x<length; x++)
	{
		cout<<Students[x].LName<<endl;
	}
	*/
}





void search(Record Students[]) //Search();
{
	bool found=false;
	ifstream inFile;
	inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/MP 2/MP 2/records.txt");
	
	cout<<"********************************************************\n"
		<<"*****************Searching for student******************\n"
		<<"********************************************************\n"
		<<"Enter the student number: ";
	cin>>studInt;
	int ctr=0;
	while (!inFile.eof() && !found && ctr<3)
	{
		inFile>> NumInFile;
		inFile.ignore(10, '\n');
		inFile>> FirstName;
		inFile.ignore(10,'\n');
		inFile>>MiddleName;
		inFile.ignore(10,'\n');
		inFile >> LastName;
		inFile.ignore(10,'\n');
		if (NumInFile==studInt)
		{
			cout<<"Yahoo!"<<endl;
			found=true;
			continue;
		}
		system("CLS");
		cout<<"********************************************************\n"
			<<"*****************Searching for student******************\n"
			<<"********************************************************\n"
			<<"\n\n Please wait for a few moments\n as the program searches the record..."<<endl<<endl;
		Sleep(500);
	}
	if (found)
	{
		cout<<"The information of the student are the following. "<<endl;
		cout<<"Full name: "<<LastName<<", "<< FirstName<<' '<<MiddleName<<' '<<endl;
	}
	else
	{
		cout<<"Sorry, the student ID you entered was not found"<<endl;
	}
	system("pause");
	//I did'nt include the inFile.close Because there will be a 
	//logic error in search function.

}

You'll have to search for a student using there student numbers, then display name, surname etc and ask if they want to edit it, individually though

You'll have to search for a student using there student numbers, then display name, surname etc and ask if they want to edit it, individually though

thats what im on.. i fail to achieve the right codes...
and there's some problem upon registration, it wont allow u to input the first name..

Oh, well I assumed you had everything sorted because you were asking for help on the edit part

Oh, well I assumed you had everything sorted because you were asking for help on the edit part

forgive my grammar if u mistook it as the edit you've thought, anyways this is my edit function which supposed change the name,middle name, and last name of the student he wishes to edit provided the student id he inputted matches to any

void searchED(Record Students[]) //Search();
{
	int i=0;
	char editDecider;
	bool found=false;
	ifstream inFile;
	ofstream outFile;
	outFile.open("records.txt", ios::app); //We open.
	inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/records.txt");
	
	cout<<"********************************************************\n"
		<<"*****************Searching for student******************\n"
		<<"********************************************************\n"
		<<"Enter the student number: ";
	cin>>studInt;
	int ctr=0;
	while (!inFile.eof() && !found)
	{
		inFile>> NumInFile;
		inFile.ignore(10, '\n');
		inFile>> FirstName;
		inFile.ignore(10,'\n');
		inFile>>MiddleName;
		inFile.ignore(10,'\n');
		inFile >> LastName;
		inFile.ignore(10,'\n');
		i++;
		if (NumInFile==studInt)
		{
			cout<<"Searching complete:\n Student Found."<<endl;
			found=true;
			continue;
		}
	inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/records.txt");

		system("CLS");
		cout<<"********************************************************\n"
			<<"**************Editing a record of student***************\n"
			<<"********************************************************\n"
			<<"\n\n Please wait for a few moments\n as the program searches the record..."<<endl<<endl;
		Sleep(500);
	}
	if (found)
	{
		
		cout<<"The information of the student are the following. "<<endl;
		cout<<"Full name: "<<LastName<<", "<< FirstName<<' '<<MiddleName<<endl
			<<"student ID:"<<studInt<<" is on slot "<<i<<endl; 
		cout<<"========================================================\n";
		system("Pause");
		system("CLS");
		/*inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/records.txt");
		while (studInt!=NumInFile)
		{
		inFile>> NumInFile;
		inFile.ignore(10, '\n');
		inFile>> FirstName;
		inFile.ignore(10,'\n');
		inFile>>MiddleName;
		inFile.ignore(10,'\n');
		inFile >> LastName;
		i++;
		}*/
		int tempI;
		tempI=i;
		cout<<"********************************************************\n"
			<<"**************Editing a record of student***************\n"
			<<"********************************************************\n"
			<<"You are on slot "<<tempI<<endl<<endl;
		system("pause");
		Students[i].StudNum; 
		outFile<<Students[i].StudNum<<endl;
		
		cout<<"Enter your New First Name: "<<flush;
		getline(cin,Students[i].FName);
		outFile<<Students[i].FName<<endl;

		cout<<"Enter your New Middle Name: ";
		getline(cin,Students[i].MName);
		outFile<<Students[i].MName<<endl;


		cout<<"Enter your New Last Name: ";
		getline(cin,Students[i].LName);
		outFile<<Students[i].LName<<endl;
	

		cout<<"Your student number is: "<<studInt<<endl;
		system("pause");
		system("CLS");
	}
	else
	{
	cout<<"Search Complete.\n"
		<<"Sorry, the student ID you entered was not found"<<endl;
	}
	system("pause");
}

So does this search and edit function work?

the search works, as for the edit no good luck... after outputting the item it had found which is correct, the edit part of the edit function adds another student and that's where i hit rock bottom, i couldn't figure how will it manipulate the information found after the searching

Use tempI in place of i for your edited records, this will continue to use the existing record and change it accordingly, without creating a totally new one.

Use tempI in place of i for your edited records, this will continue to use the existing record and change it accordingly, without creating a totally new one.

ive tried this but it didt not change.. it still created the last runs output.. i'll try to check wheter i've mistakenly put some incorrect variables

Use tempI in place of i for your edited records, this will continue to use the existing record and change it accordingly, without creating a totally new one.

ive tried this but it didt not change.. it still created the last runs output..
the simulation goes like this..
search complete:
student found
full name: (last name ),(first) (middle name)
student id: 2010 and is on slot 1
============================================
then this will be the output when it will prompt u to change the information:

input new first name: input new middle name:

==================
and so it goes ...it does not allow me to input a first name then it skips to the middle name
and still not changing the record but creates a new one

Edited 5 Years Ago by existinglady: n/a

your on the right track, and I didn't read through all of the code so there may be a few mistakes in what I'm about to write, but here is the general path you want to take:

In your initial menu I would recommend putting a fourth option that says "modify student record." prompt the user for the id number and then search through it using the search function you already have in place. Get the search function to return a pointer to the student record and then your good.

Once you have that...

void modifyStudentRecord(struct Record * ptr) { 

string response ; 

cout << "which element of the student record would you like to modify" << endl ; 

cin >> response ; 

cout << endl ; 

if ( ( strcmp(response, "FirstName") == 0 ) { 
    cout << "Enter the modified first name" << endl ;
    cin >> response ; 
    strcpy(response, ptr->FName) ; // or maybe . instead of ->
                       // you'll figure it out

}
 /* and so on and so fourth until you loop through every element 
    of the structure */






}

Edited 3 Years Ago by Nick Evan: Fixed formatting

your on the right track, and I didn't read through all of the code so there may be a few mistakes in what I'm about to write, but here is the general path you want to take:

In your initial menu I would recommend putting a fourth option that says "modify student record." prompt the user for the id number and then search through it using the search function you already have in place. Get the search function to return a pointer to the student record and then your good.

Once you have that...

void modifyStudentRecord(struct Record * ptr) {

string response ;

cout << "which element of the student record would you like to modify" << endl ;

cin >> response ;

cout << endl ;

if ( ( strcmp(response, "FirstName") == 0 ) {
cout << "Enter the modified first name" << endl ;
cin >> response ;
strcpy(response, ptr->FName) ; // or maybe . instead of ->
// you'll figure it out

}
/* and so on and so fourth until you loop through every element
of the structure */


}

ive created my edit func since im having a hard time with pointers
here is my edit function... i just copied the way it search() works then i lets the user re-enter the new first,middle, and last name altogether but it does not overwrite the space which is hard for me to figure out why

void searchED(Record Students[]) //Search();
{
	string newFName,newMName,newLName;
	int i=0;
	char editDecider;
	bool found=false;
	ifstream inFile;
	ofstream outFile;
	outFile.open("records.txt", ios::app); //We open.
	inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/records.txt");
	cout<<"********************************************************\n"
		<<"*****************Searching for student******************\n"
		<<"********************************************************\n"
		<<"Enter the student number: ";
	cin>>studInt;
	int ctr=0;
	while (!inFile.eof() && !found)
	{
		inFile>> NumInFile;
		inFile.ignore(10, '\n');
		inFile>> FirstName;
		inFile.ignore(10,'\n');
		inFile>>MiddleName;
		inFile.ignore(10,'\n');
		inFile >> LastName;
		inFile.ignore(10,'\n');

		if (NumInFile==studInt)
		{
			cout<<"Searching complete:\n Student Found."<<endl;
			found=true;
			//continue;
		}
	//inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/records.txt");

		system("CLS");
		cout<<"********************************************************\n"
			<<"**************Editing a record of student***************\n"
			<<"********************************************************\n"
			<<"\n\n Please wait for a few moments\n as the program searches the record..."<<endl<<endl;
		Sleep(500);
	}
	if (found)
	{
		
		cout<<"The information of the student are the following. "<<endl;
		cout<<"Full name: "<<LastName<<", "<< FirstName<<' '<<MiddleName<<endl
			<<"student ID:"<<studInt<<" is on slot "<<i<<endl; 
		cout<<"========================================================\n";
		system("Pause");
		system("CLS");
		int tempI;
		tempI=i;
		cout<<"********************************************************\n"
			<<"**************Editing a record of student***************\n"
			<<"********************************************************\n"
			<<"You are on slot "<<tempI<<endl;
		
		system("pause");

		Students[tempI].StudNum=2010+tempI; 
		outFile<<Students[tempI].StudNum<<endl;
		cout<<endl;
		cout<<"Enter your New First Name: "<<flush;
		cin>>newFName;
		Students[tempI].FName=newFName;
		outFile<<Students[tempI].FName<<endl;

		cout<<"Enter your New Middle Name: ";
		cin>>Students[tempI].MName;
		outFile<<Students[tempI].MName<<endl;


		cout<<"Enter your New Last Name: ";
		cin>>Students[tempI].LName;
		outFile<<Students[tempI].LName<<endl;
	

		cout<<"Your student number is: "<<studInt<<endl;
		system("pause");
		system("CLS");
	}
	else
	{
	cout<<"Search Complete.\n"
		<<"Sorry, the student ID you entered was not found"<<endl;
	}
	system("pause");
}

Put cin.ignore() before you input the first name

ok.. it does prompt me now to input first name.. but still i does not replace the information i want to change
i looks like this
2011
yjasmin
dog
cute
2011
newyjasmin
cute
dog

it does not replace the information i want to change

Okay here's one of my old homework assignments for you to have a look at, it also involves editing:

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

struct studentType
{
	long studentNr;
	string surname;
	string name;
};

void main()
{
	studentType stud, newStud;
	ifstream inFile;
	ofstream outFile;
	long number;
	char choice, choice2;

	inFile.open("students.txt");

	if(inFile)
	{
		outFile.open("temp.txt");

		cout << "Please enter student number that you wish to edit: " << endl;
		cin >> number;
		inFile >> stud.studentNr;

		while(inFile)
		{
			inFile >> stud.surname;
			inFile >> stud.name;

			if(number == stud.studentNr)
			{
				newStud.studentNr = stud.studentNr;
				cout << "Last name: " << stud.surname << endl;
				cout << "Edit this record (y/n)?";
				cin >> choice;

				if(choice == 'y' || choice == 'Y')
				{
					cout << "Please enter new value: ";
					cin >> newStud.surname;
				}
				else
					newStud.surname = stud.surname;

				cout << "First name: " << stud.name << endl;
				cout << "Edit this record (y/n)?";
				cin >> choice2;

				if(choice2 == 'y' || choice2 == 'Y')
				{
					cout << "Please enter new value: ";
					cin >> newStud.name;
				}
				else
					newStud.name = stud.name;

				outFile << newStud.studentNr << endl;
				outFile << newStud.surname << endl;
				outFile << newStud.name << endl;
			}
			else
			{
				outFile << stud.studentNr << endl;
				outFile << stud.studentNr << endl;
				outFile << stud.studentNr << endl;
			}
			stud.studentNr;
		}

		inFile.close();
		outFile.close();
		remove("students.txt");
		rename("temp.txt", "students.txt");
	}
	else
		cerr << "Error. File not found" << endl;
}

Okay here's one of my old homework assignments for you to have a look at, it also involves editing:

you code is good sir, but my team leader wants the program to overwrite the specifice information in the studtenst.txt.. he wants it to look fromm left to right
2010-------------->2010
name1------------->name1
lname1------------>lname1
2011-------------->2011
name2------------->name4
lname2------------>lname4
2012-------------->2012
name3------------->name3
lname3------------>lname3
and i cant seem to make it work

I don't quite understand what you mean from left to right, is it suppose to show the new details next to the old ones like: old details------------->new details, or what?

Instead of writing out to your output file every time you do something, try separating your logic into:
1) read the input file into your array
2) loop over user input, adding students to the array, removing students from the array, or editing students already in the array
3) when the user chooses "Quit", write the student array out to the output file

Consider having your search-routine return the array-index of the student you're searching for (and maybe an obvious non-index like -1 if the search fails).

Your edit function shouldn't do a search. Instead when the user chooses the "Edit" option, first perform a search using your search function, and if successful then call your edit function, otherwise print an error message that the specified student wasn't found.

Instead of writing out to your output file every time you do something, try separating your logic into:
1) read the input file into your array
2) loop over user input, adding students to the array, removing students from the array, or editing students already in the array
3) when the user chooses "Quit", write the student array out to the output file

Consider having your search-routine return the array-index of the student you're searching for (and maybe an obvious non-index like -1 if the search fails).

Your edit function shouldn't do a search. Instead when the user chooses the "Edit" option, first perform a search using your search function, and if successful then call your edit function, otherwise print an error message that the specified student wasn't found.

actually during my offline days i was able to make it in 5 hours with full focus... could i post it on the forums? so others would get some basis if they plan on making this kind of program

Yes please do, that would be very helpful

in a few days im going to share it but it still need some few polishing(there were some useless functions of my first attempts and some variables) and Im thinking off adding a changelog...

here is the final code that i've managed to make please note that i finished this thing in 5 hours and did not add much functions to the program because i also focused on the things that our team needs to achieve which only consist of editing, searching, adding, and printing all the records.
OH another note, make sure to change all the fstream destinations to the locaiton of your desire otherwise it wont work...
i had a little problem sharing this with my teammates because they forgot to change the address of the fstreams.

#include <iostream>
#include <string>
#include <fstream>
#include <cctype>
#include <iomanip>

using namespace std;

struct Record
{
	string FName , LName , MName;
	int StudNum;
};
//Declaration for the struct.
Record Students[50],Students2[50];
//The User=Defined Functions.
int main2();
void Register(Record Students[]);
void search(Record Students[]);
void EditRecord(Record Student[]);
void perfromPrintAll(Record Students[]);
void changelog();
//Global Declaration of variables;

int studInt;
int length=0;
char response;
int z=0;
//Declaration for the registration function.
//Declaration for the search function.
string LastName,FirstName, MiddleName;
int NumInFile; 
//Main program.

int main()
//this serves as a title page which would eventually turn into the main menu after pressing any key

{
	cout<<"\n"
	<<"   *******                                 \n"
	<<"  ****   **  *******   * ***  **** *   *******  \n"
	<<" ****           *  *   * *  * *    **  *  *    \n"
	<<"*****           *  *   * *  * ***  * * *  *    \n"
	<<" *****          *  *   * *  * *    *  **  *    \n"
	<<"   *****        *  *   * *  * *    *   *  *    \n"
	<<"    ******      *  ***** ***  **** *   *  *     \n"
	<<"     ******\n"
	<<"     ******* ****  **** **** **** ****  ***  \n"
	<<"      ****** *   * *    *  * *  * *  ** *  * \n"
	<<" *   ******  ****  ***  *    *  * ****  *   * \n"
	<<"*** *****    *  *  *    *  * *  * *  *  *   *\n"
	<<" ******      *   * *    *  * *  * *   * *  *  \n"
	<<"  ****       *   * **** **** **** *   * ***  \n"
	<<"\t\t\t\t\t By: Logistics\n"
	<<"\t\t\t\t\t Version: 3.5 \n\n\t\t";
	system("Pause");
	system("CLS");
	main2();
	return 0;
}
int main2()
// Main menu which allows users to select function they wish to use
{
	//length=0;
	bool found=false;
	char choice;
	string CHOICE;
	do
	{
	//The user will choose what to do.
	cout<<"====================================================================\n"
		<<"========================STUDENT RECORD==============================\n"
		<<"==============================================by:Logistics==========\n"
		<<"===============================================version 3.5==========\n"
		<<"--------------------------------------------------------------------\n"
		<<" [1] => Registration.\n"                    
		<<" [2] => Search the student record.\n"
		<<" [3] => Edit a record.\n"
		<<" [4] => Print all Records.\n"
		<<" [5] => Quit.\n"
		<<"Your choice: ";
	cin>>choice;
	if (getline(cin, CHOICE)) // To delete the other unnecesary letters.
		
	switch(choice)
	{
	case '1':
		{
			system("CLS");
			length=0;
			Register(Students);
			break;
		}
	case '2':
		{
			system("CLS");
			length=0;
			search(Students); //Students because we have declared that as a identifier of the struct.
			break;
		}
	case '3':
		{
			system("CLS");
			length=0;
			EditRecord(Students);//Students because we have declared that as a identifier of the struct. this time we'll be able to change a student record
			break;
		}
	case '4':
		{
			system("cls");
			length=0;
			perfromPrintAll(Students);
			break;
		}
	case '5':
		{
			system("CLS");
			cout<<"====================================================================\n"
			<<"========================STUDENT RECORD==============================\n"
			<<"==============================================by:Logistics==========\n"
			<<"===============================================version 3.5==========\n"
			<<"--------------------------------------------------------------------\n";
			cout<<"Thank you for using our student record program...\n";
			system("pause");
			exit(0);
			break;
		}
	default:
		{
			cout<<"your choice is not on the list"<<endl;
			cout<<"As a result, the program will return you to the main menu\nif you dont have any more transactions in mind\nchoose 5 to quit"<<endl;
			system("pause");
			system("CLS");
			continue;
		}
		break;
	} 
	system("CLS");
	cout<<"====================================================================\n"
		<<"========================STUDENT RECORD==============================\n"
		<<"==============================================by:Logistics==========\n"
		<<"===============================================version 3.5==========\n\n"
		<<"--------------------------------------------------------------------\n";
	cout<<"Want another transaction? (Y/N) ";
	cin>>choice;
	switch(choice)
	{
	case 'Y':
		{
			system("CLS");
			return main2();
			break;
		}
	case 'y':
		{
			system("CLS");
			return main2();
			break;
		}
	case 'N':
		{
			system("CLS");
		
			cout<<"====================================================================\n"
			<<"========================STUDENT RECORD==============================\n"
			<<"==============================================by:Logistics==========\n"
			<<"===============================================version 3.5==========\n\n"
			<<"--------------------------------------------------------------------\n";
			cout<<"Thank you for using our student record program...\n";
			system("pause");
			exit(0);
			break;
		}
	case 'n':
		{
			system("CLS");
		
			cout<<"====================================================================\n"
			<<"========================STUDENT RECORD==============================\n"
			<<"==============================================by:Logistics==========\n"
			<<"===============================================version 3.5==========\n\n"
			<<"--------------------------------------------------------------------\n";
			cout<<"Thank you for using our student record program...\n";
			system("pause");
			exit(0);
			break;
		}
	default:
		{
			system("CLS");
			cout<<"====================================================================\n"
			<<"========================STUDENT RECORD==============================\n"
			<<"==============================================by:Logistics==========\n"
			<<"===============================================version 3.5==========\n\n"
			<<"--------------------------------------------------------------------\n";
			cout<<"Your choice is not on the list"<<endl;
			cout<<"As a result, the program will return you to the main menu\nif you dont have any more transactions in mind\nchoose 5 to quit"<<endl;
			system("pause");
			system("CLS");
			break;
		}
	}
	}
	
	while (!found);
	return 0;
} 
void EditRecord(Record Students[])
// This function allows users to locate a certain student number and edit it's contents
{
	Record Student2[50];
	ifstream infile;
	ofstream outfile;
	int i=0,searchSID=0;
	infile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/recordss.txt");
	while(!infile.eof())
	{ 
		infile>>Students2[i].StudNum
			>>Students2[i].FName
			>>Students2[i].MName
			>>Students2[i].LName;
		i++;
		length++;
	}
	for(i=0;i<length;i++)
	{
		Students[i].StudNum=Students2[i].StudNum;
		Students[i].FName=Students2[i].FName;
		Students[i].MName=Students2[i].MName;
		Students[i].LName=Students2[i].LName;
	}
	length-=1;
	cout<<"===============================================================================\n"
		<<"========================STUDENT RECORD=========================================\n"
		<<"==============================================by:Logistics=====================\n"
		<<"===============================================version 3.5=====================\n\n";
	cout<<"Please enter the student number you want to edit:\n";
	cin>>searchSID;
	cout<<endl;
	int index;
	if(searchSID<2010)
	{
		system("CLS");
		cout<<"===============================================================================\n"
			<<"========================STUDENT RECORD=========================================\n"
			<<"==============================================by:Logistics=====================\n"
			<<"===============================================version 3.5=====================\n\n";
			cout<<"Sorry the Student ID number "<<searchSID<<" is not on the record, thus it does not exist"<<endl;
		cout<<"-------------------------------------------------------------------------------\n\n"
			<<"the program will return to the main menu.."<<endl;
			system("pause");
		system("CLS");
			main2();
	}
	else if(searchSID>=2010+length)
	{
		system("CLS");
		cout<<"===============================================================================\n"
			<<"========================STUDENT RECORD=========================================\n"
			<<"==============================================by:Logistics=====================\n"
			<<"===============================================version 3.5=====================\n\n";
			cout<<"Sorry the Student ID number "<<searchSID<<" is not on the record, thus it does not exist"<<endl;
		cout<<"-------------------------------------------------------------------------------\n\n"
			<<"the program will return to the main menu.."<<endl;
			system("pause");
		system("CLS");
			main2();
	}
	else
	{
	for(index=0;index<length;index++)
	{
		
		if(searchSID==Students[index].StudNum)
		{
			system("CLS");
			cout<<"===============================================================================\n"
				<<"========================STUDENT RECORD=========================================\n"
				<<"==============================================by:Logistics=====================\n"
				<<"===============================================version 3.5=====================\n\n"
				<<"Student's information:\n"
				<<"===============================================================================\n\n";
			cout<<"Slot:"<<index+1<<endl;
			cout<<"Student ID:"<<Students[index].StudNum<<endl
				<<"First Name:"<<Students[index].FName<<endl
				<<"Middle Name:"<<Students[index].MName<<endl
				<<"Last Name:"<<Students[index].LName<<endl;
			cout<<"Procede to change the student's information"<<endl
				<<"-------------------------------------------------------------------------------\n";
			system("pause");
			system("CLS");
			cout<<"===============================================================================\n"
			<<"========================STUDENT RECORD=========================================\n"
			<<"==============================================by:Logistics=====================\n"
			<<"===============================================version 3.5=====================\n\n"
			<<"Student's registration form: PLEASE USE PASCAL CASING AND INCASE YOUR NAME IS \n"
			<<"TWO, TYPE THEM ALTOGETHER WITHOUT SEPARATION, eg. JohnPaul,JohnnMichael\n"
			<<"===============================================================================\n\n";
			cout<<"Enter Student "<<Students[index].LName<<"'s new Information:"<<endl;
			cout<<"Enter the new first Name: ";
			cin>>Students[index].FName;
			cout<<endl;
			cout<<"Enter the new Middle Name:";
			cin>>Students[index].MName;
			cout<<endl;
			cout<<"Enter the new Last Name:";
			cin>>Students[index].LName;
			cout<<endl;
		}
	}
	outfile.open("recordss.txt");
	for(index=0;index<length;index++)
	{
		outfile<<Students[index].StudNum<<"\t"<<Students[index].FName<<"\t"<<Students[index].MName<<"\t"<<Students[index].LName<<endl;
	}
	outfile.close();
	system("pause");
}
}
void Register(Record Students[])
//allows user to register students
{
	length=50;
	ofstream outfile;
	ifstream infile;
	int i=0;
	infile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/recordss.txt");
	while(!infile.eof() && i<length)
	{
		infile>>Students[i].StudNum
			>>Students[i].FName
			>>Students[i].MName
			>>Students[i].LName;
		i++;
	}
	length=i-1;
	outfile.open("recordss.txt",ios::app);
	cout<<"===============================================================================\n"
		<<"========================STUDENT RECORD=========================================\n"
		<<"==============================================by:Logistics=====================\n"
		<<"===============================================version 3.5=====================\n\n"
		<<"Student's registration form: PLEASE USE PASCAL CASING AND INCASE YOUR NAME IS \n"
		<<"TWO, TYPE THEM ALTOGETHER WITHOUT SEPARATION, eg. JohnPaul,JohnnMichael\n"
		<<"===============================================================================\n\n";
	cout<<"You are on Slot "<<i<<endl;
	Students[i].StudNum=2010+length;
	outfile<<Students[i].StudNum<<"\t";
	cout<<"Enter the student's first name:";
	cin>>Students[i].FName;
	cout<<endl;
	outfile<<Students[i].FName<<"\t";
	cout<<"Enter the student's middle name:";
	cin>>Students[i].MName;
	cout<<endl;
	outfile<<Students[i].MName<<"\t";
	cout<<"Enter the student's family name:";
	cin>>Students[i].LName;
	cout<<endl;
	outfile<<Students[i].LName<<"\t"<<endl;
	cout<<"Your student ID number is: "<<2010+length<<endl;
	outfile.close();
	
	system("pause");
}
void search(Record Students[]) 
//Searches the "recordss.txt" for student number that would be equal to the ID number the user wanted to find
{
	length=0;
	bool found=false;
	ifstream inFile;
	inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/recordss.txt");
	cout<<"===============================================================================\n"
		<<"========================STUDENT RECORD=========================================\n"
		<<"==============================================by:Logistics=====================\n"
		<<"===============================================version 3.5=====================\n"
		<<"-------------------------------------------------------------------------------\n"
		<<"Searching a Student.\n"
		<<"-------------------------------------------------------------------------------\n"
		<<"Enter the student number: ";
	cin>>studInt;
	while (!inFile.eof() && !found)
	{
		inFile>> NumInFile;
		inFile>> FirstName;
		inFile>>MiddleName;
		inFile >> LastName;
		if (NumInFile==studInt)
		{
			found=true;
			continue;
		}
	}
	if (found)
	{
		system("CLS");
		cout<<"===============================================================================\n"
			<<"========================STUDENT RECORD=========================================\n"
			<<"==============================================by:Logistics=====================\n"
			<<"===============================================version 3.5=====================\n"
			<<"===============================================================================\n";
		cout<<"-------------------------------------------------------------------------------\n"
			<<"The information of the student with the ID number of: "<<NumInFile<<"\nare the following. \n\n"
			<<"--------------------------------------------------------------------------------\n";
			
		cout<<"First Name: "<<FirstName<<endl
			<<"Middle Name: "<<MiddleName<<endl
			<<"Last Name: "<<LastName<<endl;
		cout<<"--------------------------------------------------------------------------------\n";

	}
	else
	{
		system("CLS");
		cout<<"===============================================================================\n"
			<<"========================STUDENT RECORD=========================================\n"
			<<"==============================================by:Logistics=====================\n"
			<<"===============================================version 3.5=====================\n"
			<<"===============================================================================\n";
		cout<<"Sorry, Student ID "<<studInt <<" was not located thus,that Student is not recorded"<<endl;
		cout<<"--------------------------------------------------------------------------------\n";
	}
	system("pause");
}
void perfromPrintAll(Record Students[])
// prints all the records from "records.txt" and are ordered by their student number also
//the slots alloted to them are showed
{
	length=0;
	ifstream infile;
	ofstream outfile;
	int i=0;
	infile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/Mp version 0.4/Mp version 0.4/recordss.txt");
	while(!infile.eof())
	{
		infile>>Students[i].StudNum
			>>Students[i].FName
			>>Students[i].MName
			>>Students[i].LName;
		i++;
		length++;
	}
	length=i;
	length-=1;
	cout<<"===============================================================================\n"
		<<"========================STUDENT RECORD=========================================\n"
		<<"==============================================by:Logistics=====================\n"
		<<"===============================================version 3.5=====================\n"
		<<"===============================================================================\n"
		<<"List of all Students Recorded ( in Student ID number order):\n\n"
		<<"Student ID#\tLast Name\tFirst Name\tMiddle Name"<<setw(10)<<"Slot\n"
		<<"==============================================================================="<<endl;
	for(i=0;i<length;i++)
	{
		cout<<Students[i].StudNum<<setw(20)<<Students[i].LName<<setw(15)<<Students[i].FName<<setw(17)<<Students[i].MName<<setw(9)<<i+1<<endl;
	}
	cout<<"-------------------------------------------------------------------------------"<<endl;
	system("pause");
}

Edited 5 Years Ago by existinglady: n/a

This question has already been answered. Start a new discussion instead.