1. 结构体,用它来描述事物。事物有其属性。
#include <stdio.h>
#include <stdlib.h>
// file(name,size)
/* struct _File{ */
/* char *name; */
/* int size; */
/* }; */
/* typedef struct _File File; */
typedef struct _File
{
char *name;
int size;
} File;
main()
{
//int arr[10]={2,3,4,5};//chu shi hua
File file={"jikexueyuan.txt",200};
/* struct File file; */
/* file.name="jikexueyuan.txt"; */
/* file.size=100; */
printf("File name is %s\n",file.name);
}
2. 结构体指针
时间: 2024-10-15 19:51:52