コード例 #1
0
ファイル: main.cpp プロジェクト: Make7UpYours/Code-Portfolio
void initalizeInstructor(Instructor& teacher)
{
	ifstream inFile;
	string office, name, dob, designation;
	char fileInput[100];
	inFile.open("instructor.txt");
	//Iterate through file until the end of file
	//Assign values for the instructor
	while (!inFile.eof())
	{
		inFile.getline(fileInput, 100);
		name = string(fileInput);
		teacher.setName(name);
		inFile.getline(fileInput, 100);
		dob = string(fileInput);
		teacher.setDOB(dob);
		inFile.getline(fileInput, 100);
		office = string(fileInput);
		teacher.setOffice(office);
		inFile.getline(fileInput, 100);
		designation = string(fileInput);
		teacher.setDesignation(designation);
	}
	inFile.close();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: baw5xc/CS-201-L
int main(){
	

	int numberOfStudents;
	
	char charInfo[20];
	ifstream myFile;
	string tempStr;

	Student students[20];
	Instructor professor;
	Course course;

	myFile.open("course.txt");

	while (!myFile.eof()){

		myFile.getline(charInfo, 20);
		tempStr = string(charInfo);
		course.setCourseName(tempStr);

		myFile.getline(charInfo, 20);
		tempStr = string(charInfo);
		course.setCourseID(tempStr);

		myFile.getline(charInfo, 20);
		tempStr = string(charInfo);
		course.setNumberOfStudents(tempStr);
	}

	ifstream infile;

	infile.open("instructor.txt");
	while (!infile.eof()){
		infile.getline(charInfo, 20);
		tempStr = string(charInfo);
		professor.setName(tempStr);
		
		infile.getline(charInfo, 20);
		tempStr = string(charInfo);
		professor.setDOB(tempStr);

		infile.getline(charInfo, 20);
		tempStr = string(charInfo);
		professor.setOffice(tempStr);

		infile.getline(charInfo, 20);
		tempStr = string(charInfo);
		professor.setDesignation(tempStr);
	}
	
	ifstream studentFile;
	int k = 0;

	while (!studentFile.eof()){
		
		studentFile.getline(charInfo, 20);
		tempStr = string(charInfo);
		students[k].setName(tempStr);

		studentFile.getline(charInfo, 20);
		tempStr = string(charInfo);
		students[k].setID(tempStr);

		studentFile.getline(charInfo, 20);
		tempStr = string(charInfo);
		students[k].setDOB(tempStr);

		studentFile.getline(charInfo, 20);
		tempStr = string(charInfo);
		students[k].CGPA(tempStr);

		
		numberOfStudents += 1;
		k += 1;
	}

	


	return 0;
}