cin

the last line for cin>>Student.Name; is giving me issue can someone help please

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
#include<iostream>
#include<string>

using namespace std;

//struct with all the info

struct Student
{
	string Name;  //student's name
	int IDnum;    //student's ID number
	int Tests;    //students Test score
	double Average;  // the average score
	double Grade;    //the final grades
	
};
//end of the struct
//function prototype begins
void getData(Student *);
void calcLtr(Student *);
void printReport(Student *);
//end of prototype
//begin int main
int main()
{
	Student freshman; 
	
	//get the student data
	
	cout<<"\nEnter the student Data";
    getData(&freshman); //pass the address of freshman
    cout<<"\nHere is the student Data you entered";
    
    //calculate students grade
    cout<<
    
}

void getData(Student *)
{
	//get the student name
	cout<<"\nStudent name: ";
	cin>>Student.Name;
}
whazzup with line 35? this may be propagating weird compiler errors.

perhaps this? Student is a type, not a variable, you need a variable of that type to use it...

void getData(Student *s)
{
//get the student name
cout<<"\nStudent name: ";
cin>>s[0].Name;
}

better: (why the pointer?)

void getData(Student &s)
{
//get the student name
cout<<"\nStudent name: ";
cin>>s.Name;
}
Last edited on
Topic archived. No new replies allowed.