Hi all,
I have the below function which I want to return a pointer to the array of type struct. However, I'm unsure of the syntax; what do I need to type as the return type of the function and in the prototype? I have tried the following (as per what I'd read in similar threads online):
Code:
struct *initialise()
but that doesn't work.
Also with regards to returning the pointer which of the following would be correct:
Code:
return *playersPtr;
return &playersPtr;
return playerPtr;
Code:
int initialise()
{
int currentPlayer = 0;
struct player
{
int cnt_scoreC, cnt_scoreT, cnt_startScore, numDarts, cnt_legs,
cnt_sets, clk_currentNum, clk_startNum, s_numDarts, s_won,
s_lost, s_played;
float cnt_dartAve;
char name[15];
};
struct player players[MAXPLAYERS]; //players struct array
struct player *playersPtr; //pointer capable of pointing to struct player
playersPtr = &players[MAXPLAYERS]; //put address of players array into players pointer
//return playersPtr;
}
Thanks in advance.
PS: I have put comments next to the pointer stuff on what I thought was happening, can anyone confirm if this is right?