指向指向应用程序状态结构的指针的以空结尾的数组的指针



我需要创建一个指针指向一个以null结尾的数组,该数组指向应用程序状态结构:

typedef struct _wfs_vdm_status
{
WORD wDevice;
WORD wService;
LPWFSVDMAPPSTATUS * lppAppStatus;
LPSTR lpszExtra;
} WFSVDMSTATUS, * LPWFSVDMSTATUS;

typedef struct _wfs_vdm_appstatus
{
LPSTR lpszAppID;
WORD wAppStatus;
} WFSVDMAPPSTATUS, * LPWFSVDMAPPSTATUS;

但是创建lppAppStatus参数非常困难。如有任何帮助,不胜感激

所以我有点不清楚你要创建的结构。创建以空结尾的_wfs_vdm_appstatus字符串数组的一般过程如下

main (int argc, char **argv)
{
int NUMBER_OF_ELEMENTS=10;
int i = 0;
/* you would allocate your 10 elements and add one to null terminate them */
lppAppStatus = malloc (NUMBER_OF_ELEMENTS+1) * sizeof(LPWFSVDMAPPSTATUS);
/* each of these elements would need to have memory allocated */
for (i=0;i<NUMBER_OF_ELEMENTS;i++)
{
   lppAppStatus[i] = malloc(sizeof (struct _wfs_vdm_appstatus));
}
/* null terminate your array */
lppAppStatus[NUMBER_OF_ELEMENTS] = NULL;
}

我的C有点生疏,所以你可能需要摆弄一下这个

相关内容

  • 没有找到相关文章