
newbie question: passing struct as argument to function ?
I'm having major difficulties trying to pass a struct-array to a
function as a parameter, modify the parameter, and get the modified
variable out of the function.
------------------
typedef struct {
short recTypeID;
SYSTEMTIME sysDate;
TCHAR comment[COMMENT_LENGTH];//comment
Quote:
} PersonalNotesInfo;
//Function that takes a PersonalNotesInfo-variable as an argument
//and fills that array with data
int GetPersonalNotesListPerPupil(short pupSubID, PersonalNotesInfo
*personalNotesInfoList)
{
int i, numOfItems;
...
...
//Allocating the PersonalNotes list
numOfItems = CountNumberOfItems(); //Get number of records
personalNotesInfoList = new PersonalNotesInfo[numOfItems];
for (i = 0; i < numOfItems; i++)
{
// insert data into the parameter
personalNotesInfoList[i].recTypeID = i;
...
}
...
return numOfItems;
Quote:
}
void main_function()
{
int i, numOfNotes;
PersonalNotesInfo *personalNotesInfoList;
// Sends the personalNotesInfoList-variable into the function, and
// want it return initialized and with data
numOfNotes = GetPersonalNotesListPerPupil(1,
&personalNotesInfoList);
...
...
Quote:
}
-------------------
In the main_function, the call to GetPersonalNotesListPerPupil gives
the following compil-error:
error C2664: 'GetPersonalNotesListPerPupil' : cannot convert parameter
2 from 'PersonalNotesInfo ** ' to 'PersonalNotesInfo *'
Can someone please tell me what I've messed up here ? I'm starting to
get frustrated here.......
- Ole Bredesen-Vestby