need help please

i need help on a few things in my program here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const int NUM_SCORES = 6;
	typedef struct 
	{
		int day;
		int month;
		int year;
	} Date;
	struct Student 
	{
		int number;
		Date dob;
		float scores[NUM_SCORES];
	}; Student student;

	const int 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

i really hope someone can help. thanks in advance
can someone please help with this?
closed account (zb0S216C)
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.

Wazzak
Last edited on
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
Topic archived. No new replies allowed.