/*C++使用new关键字分配内存,而C使用malloc(memory allocate)来分配内存*/
#include <stdio.h>
#include <malloc.h>
/*使用typedef把int类型命名为新类型xx*/
typedef int ElemType;
typedef int Status;
/*结构体定义*/
typedef struct{
ElemType *elem;
int length;
}SqList;
Status InitList_Sq(SqList L){
L.elem=(int *)malloc(sizeof(100));
if(!L.elem) exit(404);
L.length=0;
printf("%d",L.length);
return 0;
}
int main(){
/*类型变量*/
SqList Sq;
InitList_Sq(Sq);
return 0;
}
C语言数组初始化
最新推荐文章于 2024-08-29 22:56:19 发布