I direly need help with passing an array of structures into a function.
The problem is that Main_menu.name is blank. What is the correct syntax to pass by reference, so that I will get the Main_menu.name in main()? I would like to use pointer in the createMenu function for efficiency. createMenu function reads data from a resource file and assigns the value to the field.
Would someone please help? Thanks.
Struct menu
{
int Id;
char name[10];
};
menu Main_menu[10];
void createMenu (menu* menuPtr);
{
While (!numData.getline(inputId,10, '$').eof())
{
menuPtr->Id = inputId;
getline( inputName, 10, '\n');
strcat(menuPtr->name, inputName);
menuPtr++;
}
}
int Main ()
{
createMenu(Main_menu);
For (int i= 0; I < 10; i++)
{ Cout << Main_menu.id << Main_menu.name << endl;}
return 0;
}
<< moderator edit: added code tags: [co[u][/u]de][/co[u][/u]de]
>>