私が開発しているプログラムでは、次の構造を持っています。
typedef struct _event {
int id;
char title[30];
char desc[60];
int state;
} event;
このプログラムの特定の部分で、この構造体へのポインターを必要とする関数を使用します。
void event_foo(event *e)
{
/* Something will be done on this function,
with certain parameters of the pointer to the struct are needed */
}
しかし、この関数にアクセスする前に、構造体へのこのポインタにメモリを割り当てる必要があります。
int main()
{
event newevent;
/* In some place before invoking the function,
memory assignation is required */
event_foo(&newevent);
return 0;
}
それを行うための提案はありますか?