I've looked around for about an hour and can't find anything that was to terribly helpful, or I didn't know how to use it. So here it is.
#include<iostream>
#include<new>
#include<cstdlib>
#include<string>
using namespace std;
struct student {
string name;
double gpa;
};
student doSurvey(student s);
void reportSurvey(student s);
int main()
{
student myStu;
student * pStu;
pStu = &myStu;
int i, n;
cout << "How many surveys are going to be entered? ";
cin >> i;
pStu= new (nothrow) student[i];
if(i == 0){
cout << "No surveys entered.";
} else {
for(n=0; n<i; n++){
doSurvey(pStu[i]);
}
for(n=0; n<i; n++){
reportSurvey(pStu[i]);
}
}
system("PAUSE");
return 0;
}
student doSurvey(student s){
cout << "Students name: ";
cin >> s.name;
cout << "Students GPA: ";
cin >> s.gpa;
return s;
}
void reportSurvey(student s){
cout << "Name: " << s.name << endl;
cout << "GPA: " << s.gpa << endl;
}
Exact Error:
error C2146: syntax error : missing ';' before identifier 'pStu'
Error Code:
pStu= new (nothrow) student pStu[i];
Still trying to figure out how to use pointers and everything so I probably messed up with them.