- 论坛徽章:
- 0
|
像下面这样的结构里面带有结构数组指针的,我怎么调用?能编译,一执行就报指针越界错误,malloc了也没用。
#include "stdafx.h"
#include <malloc.h>
#include <stdio.h>
#include <memory.h>
typedef struct _myinfo_detail
{
long Number;
char Type[256];
} MyInfoDetail, * LPMyInfoDetail;
typedef struct _myinfo
{
long Count;
LPMyInfoDetail *MyList;
} MyInfo, * LPMyInfo;
int main(int argc, char* argv[])
{
MyInfo myinfo;
// myinfo=(LPMyInfo)malloc(sizeof(MyInfo));
myinfo.MyList=(LPMyInfoDetail* )malloc(sizeof(MyInfoDetail)*10);
myinfo.Count=3;
for(int i=0;i<myinfo.Count;i++)
{
myinfo.MyList[i]->Number=i;
}
printf("Hello World!\n");
return 0;
} |
|
|