constint NUM_SCORES = 6;
typedefstruct
{
int day;
int month;
int year;
} Date;
struct Student
{
int number;
Date dob;
float scores[NUM_SCORES];
}; Student student;
constint MAX_ITEMS = 10;
struct ListType
{
int length;
Student info[MAX_ITEMS];
}; ListType list;
struct ItemType
{
int aStudent;
int findStudent;
};
void readstudent(void);
void writestudent(void);
void BinarySearch(void);
int _tmain(int argc, _TCHAR* argv[])
{
Student student [15];
ListType list;
list.length = 0;
//all this is for displaying text file
ifstream in ("StudentFile.txt");
while(!in.eof())
for (int i = 0; i < 15; i++)
{
in >> student[i].number >> student[i].dob.day >> student[i].dob.month >> student[i].dob.year
>> student[i].scores[0]
>> student[i].scores[1]
>> student[i].scores[2]
>> student[i].scores[3]
>> student[i].scores[4]
>> student[i].scores[5];
}
cout << "The Class List Is: " << endl;
cout << "Name " << "\t" << "Date" << "\t\t" << "Scores" << endl;
for (int i = 0; i < 15; i++)
{
cout << student[i].number << "\t" << student[i].dob.day << "/" << student[i].dob.month << "/" << student[i].dob.year << "\t"
<< student[i].scores[0]
<< student[i].scores[1]
<< student[i].scores[2]
<< student[i].scores[3]
<< student[i].scores[4]
<< student[i].scores[5] << endl;
}
in.close();
return 0;
}
void readstudent(ifstream &in, ItemType &aStudent)
{
cout << "Enter a student number : ";
in >> student.number;
in >> student.dob.day >> student.dob.month >> student.dob.year;
for (int i = 0; i < NUM_SCORES; i++)
{
in >> student.scores[i];
}
}
void writestudent(ItemType student)
{
//not sure what to put here
}
heres what i need help in:
i have to call method writestudent() to output an element of list.info of type student
enter a student number to search for a student into findStudent.number
if the student is found call writestudent() to output findStudent
First, the writestudent( ) prototype doesn't match the definition.
Based on what you've said, printing student information to the screen is a simple task. According to you, writestudent( ) performs this task. If what I've just said is true, writestudent( ) would take the information given within the student argument and present that information to the user in a given format.
list has be declared twice, by the way. One of them is global while the other is local to main( ). The compiler may know which one to use, but you might not.
ok but the problem im having is i don't know what the code should be to do all this:
call method writestudent() to output an element of list.info of type student
enter a student number to search for a student into findStudent.number
if the student is found call writestudent() to output findStudent
heres what i tired:
1 2 3 4 5 6 7 8
void writestudent(ItemType Student)
{
cout << "Enter a student number : ";
if (student.number == findStudent.number)
cout << findStudent;
else
cout << "student number not found";
}
but its not working because it says findStudent.number is undefined