Can someone explain what i need to do in order to convert this program to return a pointer in the enterCubScouts function, I've tried everything i know of and nothing is working. I Read something about useing -> instead of the normal * but I'm kind of confused. Do you use -> in tandem with * or just ->.
#include <iostream>
using namespace std;
struct CubScouts
{
string name;
int schoolGrade;
string denName;
};
CubScouts *enterCubScouts(CubScouts *scouts[], int);
void printCubScouts(CubScouts scouts[], int);
int main()
{
int numScouts;
cout << "\n\nHow many cub scouts are in your pack?\n";
cin >> numScouts;
cin.ignore();
CubScouts scouts[numScouts];
enterCubScouts(scouts, numScouts);
printCubScouts(scouts, numScouts);
return 0;
}
CubScouts *enterCubScouts(CubScouts *scouts[],int size)
{
for(int x=0; x<size; x++)
{
cout << "\nCUB SCOUT " << x+1 << ": \n";
cout << "NAME: ";
getline(cin, scouts[x].name);
cout << "\n\nGRADE (1-5): ";
cin >> scouts[x].schoolGrade;
cout << "\n\nDEN NAME: ";
cin.ignore();
getline(cin, scouts[x].denName);
cin.sync();
}
return *scouts; // This needs to be a pointer
}