摘要: typedef #include<stdio.h> int main() { //typedef给一个已经存在的类型起一个别名 //typedef不可以创建新的类型 typedef int int64; int64 a; //宏定义发生在预处理阶段,typedef是发生在编译阶段 } 预处理和编译 阅读全文
posted @ 2022-03-24 23:06 W-forever 阅读(140) 评论(0) 推荐(0)
摘要: enum DAY { MON=1, TUE, WED, THU, FRI, SAT, SUN }; (1) 枚举型是一个集合,集合中的元素(枚举成员)是一些命名的整型常量,元素之间用逗号,隔开。 (2) DAY是一个标识符,可以看成这个集合的名字,是一个可选项,即是可有可无的项。 (3) 第一个枚举 阅读全文
posted @ 2022-03-24 23:02 W-forever 阅读(54) 评论(0) 推荐(0)
摘要: #include<stdio.h> union Test{ unsigned char ch; unsigned short b; unsigned int c; }; int main(){ /* 结构体的大小可以简单地认为成最大成员的大小 结构体的大小可以简单认为成员大小的累加 共用体公有一块内 阅读全文
posted @ 2022-03-24 22:52 W-forever 阅读(34) 评论(0) 推荐(0)
摘要: #include<stdio.h> #include<string.h> struct Student{ int age; char *name; int score; }; int main() { struct student *p; //需要给p分配内存 p = (struct Student 阅读全文
posted @ 2022-03-24 22:51 W-forever 阅读(35) 评论(0) 推荐(0)
摘要: **非法使用内存导致的错误 ** #include<stdio.h> #include<string.h> #include<stdlib.h> struct test{ char *str; int a; int b; int c; }; int main(){ struct test obj; 阅读全文
posted @ 2022-03-24 22:50 W-forever 阅读(55) 评论(0) 推荐(0)
摘要: #include<stdio.h> #include<string.h> #include<stdlib.h> struct Student { int age; char name[50]; int score; }; int main() { //指针指向栈区空间 struct Student 阅读全文
posted @ 2022-03-24 22:39 W-forever 阅读(88) 评论(0) 推荐(0)
摘要: #include<stdio.h> //结构体传值和地址传值及const修饰的结构体指针变量 struct Student { int age; char name[50]; int score; }; struct Student tmp; struct Student *p1 = &tmp; p 阅读全文
posted @ 2022-03-24 22:38 W-forever 阅读(197) 评论(0) 推荐(0)
摘要: 结构体 1.struct是关键字 2.struct Student合起来才是结构体类型 3.结构体内部定义的变量不能直接赋值 4.结构体制是一个类型,没有定义变量之前,是没有分配空间,就不能赋值 #include<stdio.h> #include<string.h> struct Student{ 阅读全文
posted @ 2022-03-24 16:18 W-forever 阅读(48) 评论(0) 推荐(0)
摘要: #include<stdio.h> #include<malloc.h> int main() { int *p; int a;//定义一个栈区变量 p = &a;//指针指向栈区空间 *p = 10; printf("*p = %d\n", *p); return 0; } int main01( 阅读全文
posted @ 2022-03-24 16:11 W-forever 阅读(41) 评论(0) 推荐(0)
摘要: memset memset(void * s, int c, size_t n) 功能将s的内存区域的前n个字节以参数c填入 参数: s:需要操作内存s的首地址 c:填充的字符,c虽然为参数int,但是必须为unsigned char n:指定需要设置的大小 #include<stdio.h> #i 阅读全文
posted @ 2022-03-24 16:09 W-forever 阅读(256) 评论(0) 推荐(0)