C语言的数组

#include <stdio.h>
#include <malloc.h>

int main()
{

    /*创建静态数组*/
    int a[5];
    a[0]=0;
    a[1]=1;

    int b[]={1,2,3,4};

    typedef struct  Student{
        int age;

    }Student;

    Student c[10];
    c[0].age=10;



    /*创建动态数组*/
    int *p;
    /*定义 5个元素的数组的地址的首位置:  sizeof (int):1个Int需要的字节;malloc:申请首地址; int*:具体的数组类型*/
    p=(int*)malloc((sizeof (int)*5));
    p[0]=5;
    p[1]=10;


    return 0;
}
posted @ 2024-06-28 21:50  成强  阅读(3)  评论(0编辑  收藏  举报