C语言数组初始化

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qqqrtretretee/article/details/85036410
 /*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;
}

猜你喜欢

转载自blog.csdn.net/qqqrtretretee/article/details/85036410