How do you create a pointer from a structure? I am trying to create a program th
ID: 3559873 • Letter: H
Question
How do you create a pointer from a structure?
I am trying to create a program that receives student information then later displays it in like a table format..... I do not know how to create a pointer for the structure to receive the info or to display the info in a table format.... Please help and EXPLAIN.... I am a beginer on c++ so please try to keep it simple.
The progam functions that my teacher has provided is :
//Reads the student name, ID, and Answers from an input file
void getInformation(StudentRecord *student, int& num_std);
//Allows user to enter the Answer Key
void enterKey(char key[]);
//Calculates average grade for each student
void calculateAveAndLetter(StudentRecord *student, int number_of_students, char []);
void displayHeading();
//Displays all information for each student
void displayResults(StudentRecord * student, int number_ of_students);
//displays all reports and asks user for particular student search. If answer is yes returns //true
bool displayReport(StudentRecord * student, int number_of_students);
//if displayReport returns true searchID is called.
void searchID(StudentRecord * student, int number_ of_students);
struct Answers
{
char answer1;
char answer2;
char answer3;
char answer4;
char answer5;
};
struct StudentRecord
{
int ID;
char student_name[MAX_SIZE];//or sting name
//string name;
Answers answer;
double score;
double average;
char letter_grade;
};
Explanation / Answer
you can create a pointer for structure as
struct StudentRecord *b;
and you can access each data elemrnt of structure using b->score, b->average etc.
-> operator is used for it.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.