结构体和共同体

1. 结构体

/*
 ============================================================================
 Name        : Struct.c
 Author      : jiangkuan
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>

/*struct _File{
	char *name;
	int size;
};
typedef struct _File File;*/

typedef struct _File{
	char *name;
	int size;
} File;

int main(void) {

	//struct _File file;
	File file;
	file.name = "hello.txt";
	file.size = 100;
	printf("file name is %s\n",file.name);

	return EXIT_SUCCESS;
}

运行结果:



未完待续

猜你喜欢

转载自blog.csdn.net/qq_32639315/article/details/80602359