在一个程序,我发展我有这样的结构:分配内存的指针结构
typedef struct _event {
int id;
char title[30];
char desc[60];
int state;
} event;
在这个节目,我会用谁requieres的指针,这个结构的函数的某一部分。
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;
}
¿有任何建议吗?
我已经在程序中实现了这一点。 – SealCuadrado 2013-04-10 16:24:50
@CristianC。所以你想要做什么?这种方式为结构分配内存并处理它是正确的。 – MOHAMED 2013-04-10 16:26:19
也许你的回答是正确的,因为没有指定所需的内存类型。 – SealCuadrado 2013-04-10 17:03:21