R
Richard
I need to dynamically allocation memory at run time for the number of
student's records and their test scores for the program code below. I don't
understand what the 3 errors i got. I can anyone help.
# include <iostream>
# include <string>
using namespace std;
// structure declaration
struct student_record
{
char name[20];
int test_scores;
float average_ts;
};
// function prototypes passing structure into function
void get_dynamic_testscores(int , int , int );
void main()
{
int number_records, number_testscores, *records;
get_dynamic_testscores(number_records, number_testscores, &records);
student_record student[records];
}
void get_dynamic_testscores(int number_records, int number_testscores, int
*records)
{
//int number_records, number_testscores;
cout<<"How many student do you want to average test scores? : ";
cin >>number_records;
records = new int[number_records];
cout<<"How many do you want to calculate average for this student? : ";
cin >>number_testscores;
//another dynamically allocation memory here just like records = new
int[number_records];
}
student's records and their test scores for the program code below. I don't
understand what the 3 errors i got. I can anyone help.
# include <iostream>
# include <string>
using namespace std;
// structure declaration
struct student_record
{
char name[20];
int test_scores;
float average_ts;
};
// function prototypes passing structure into function
void get_dynamic_testscores(int , int , int );
void main()
{
int number_records, number_testscores, *records;
get_dynamic_testscores(number_records, number_testscores, &records);
student_record student[records];
}
void get_dynamic_testscores(int number_records, int number_testscores, int
*records)
{
//int number_records, number_testscores;
cout<<"How many student do you want to average test scores? : ";
cin >>number_records;
records = new int[number_records];
cout<<"How many do you want to calculate average for this student? : ";
cin >>number_testscores;
//another dynamically allocation memory here just like records = new
int[number_records];
}