struct student
{
int snum;
float exam;
float quiz;
float progass;
float labex;
float test;
};
for(i = 0; i < sentinel; i++)
{
cout << "Student Number >> ";
cin >> (WHAT SHOULD I ENTER HERE TO ASSIGN THE VALUE snum???) >> endl;
See the section on how to access members. It's worth nothing you can't just modify snum; you need to create an instance of student and modify it's snum.
buffbill: what command i should enter there so that the prog will prompt me to enter the number...
zhuge: i already browse that site many time still don't understand.. i even copy and paste the program and just edit the variable but still error keep coming out. The original had no error but when i just edit the name of variable ONLY error came out..
Normally, you'd assign values to basic data types like "int", right? So for example, this would assign something to an integer variable called "stud_snum"
1 2 3
int stud_snum; // here you say, that you have a variable "stud_snum" of an number type
cout << "Student Number >> ";
cin >> stud_snum >> endl;
so far so good. But if you got more than one variable that all are somehow should be kept together, like "stud_snum", "stud_exam", "stud_quiz" and so on... this gets confusing really quickly.
1 2 3 4 5 6
int stud_snum;
int stud_exam;
int stud_quiz; // woah.. this is not very comfertable
cout << "Student Number >> ";
cin >> stud_snum >> endl;
...
So you introduce a new type that you can use instead of "just a number". This is your "struct student". But this is only a type like "int". It's not a variable.
This means, you also need to declare a variable of the new type. Just like you declared "stud_snum"
1 2 3 4 5 6 7 8 9 10 11 12
struct student
{
int snum; // here you say what numbers belong to every "student"
float exam;
float quiz;
...
};
...
student stud; // here you have a student variable called "stud". Within the student are all the numbers
cout << "Student Number >> ";
cin >> stud.snum >> endl; // here you say that you want to use the number "snum" from the student
...
Two things about this thread that irritate me a lot:
1. OP deleting [the contents of] his post and replacing it with meaningless rubbish, meaning that no-one else with the same error he had can not find this thread and end their problem
2.
Hi jt1991, I have a solution for you, please accept private messages and I can give it to you!
Please do not give people solutions. Besides that, OP almost has it right.