10 2022 档案
摘要:这样的语法是错误的: void a = 10; void表示无类型, 这样定义一个变量a, 编译器是无法知道给a分配多大的内存空间的 #include<stdio.h> #include<stdlib.h> // 1. void 限定函数的返回值, void 函数没有返回值 void functio
阅读全文
摘要:当打开一个文件时, 系统会返回一个结构体, 这个结构体有对此文件操作的所有信息 调用fopen时,系统返回这个结构体的地址 FILE *p = fopen("a.txt") 打开一个文件 FILE *fp = fopen(path,打开方式) #include<stdio.h> #include<s
阅读全文
摘要:#include<stdio.h> #include<stdlib.h> #define FIRST 1 #define SECONED 2 #define THIRD 3 int main (void) { printf("%d, %d , %d\n",FIRST , SECONED, THIRD
阅读全文
摘要:typedef是用来给类型去别名的 用法: typedef 原类型 新类型 #include<stdio.h> #include<stdlib.h> //typedef变量取别名 int main (void) { int a = 10; typedef int u32; //typedef 原类型
阅读全文
摘要:共用体: 多个变量(不同的数据类型)共用同一块内存空间, 但是同一时刻, 只能有一个变量起作用 共用体中起作用的的成员是最后一次存放的成员 #include<stdio.h>#include<stdlib.h> //define union union myUnion{ char a; short
阅读全文
摘要:#include<stdio.h> #include<stdlib.h> struct stu { int id; int age; char name[128]; }; /* struct heima_stu { int id; int age; char names[128]; int chin
阅读全文
摘要:#include<stdio.h> #include<stdlib.h> struct stu { int id; int age; char name[128]; }; int main (void) { //结构体数组: 数组中的每一个元素都是结构体 struct stu num[5] = {{
阅读全文
摘要:只有当定义了结构体变量的时候才会分配内存空间, 比喻说 struc stu { int id; int age; char name[28]; } struct stu d; 这个时候才会分配内存空间 (1) 定义结构体类型, 以及初始化结构体变量 #include<stdio.h> //关键字 s
阅读全文
摘要:数组名:【数组名是地址常量】-- 不可以被修改 #include<stdio.h> int main (void) { int a[3] = {1,2,3};//a是数组名, 数组名是地址常量,不能被修改 int b[3] ; printf("the a is %x", a); b = a ;//
阅读全文
摘要:指针的大小与类型没有关系, 都是四字节。 int *p :int * 表示指针类型, 这是一个int 类型的指针 chr *p: chr * 表示是字符类型的指针 #include<stdio.h> int main (void) { printf("int * %d \n" , sizeof(in
阅读全文
摘要:指针和内存单元 指针: 地址 内存单元: 计算机中内存最小的存储单元。 指针的定义和使用 int a = 10; int *p = &a; *表示指针变量 *p = 250; 指针的解引用,间接引用 *p: 表示将p变量的内容取出来, 当成地址看待, 再找到该地址的内存空间 如果做左值: 存数据到空
阅读全文
摘要:多文件编程: 将多个包含不同功能函数的.c 文件, 编译在一起, 生成一个exe 文件 防止多文件重复包含, 即多文件守卫。 (在main 函数的.c 文件里面, 只导入一次,防止多次导入) (1) #program once (2)linux #inndef __HEAD_H__ //head.h
阅读全文
摘要:函数的作用:(1) 提高代码的复用率; (2)提高程序的模块性 函数的分类: (1)系统库函数, 标准c库: 导入头文件--声明函数 , 根据函数原型调用 (2)用户自定义 函数定义: 包含函数原型:返回值类型, 函数名,形参列表, 函数体(大括号一对,具体代码实现) int add(int a,
阅读全文
摘要:数组: 相同数据类型的连续存储集合 int arr[10] = {1,2,3,4,5} #include<stdio.h> #define PI 3.14 //预处理定义常量 PI int main(void) { int arr[10] = {0,1,2,3,4,5,6,7,8,9}; print
阅读全文
摘要:常量: 不会变化的数据 1. “hello” 字符串常量,‘A’ 字符常量,-10整型常量,3.14浮点常量 2 . #define PI 3.14 , 宏定义 , 推荐 3. const a = 10 const 关键字, 被该关键字修饰的变量, 表示为只读变量 #include<stdio.h>
阅读全文
摘要:计算机系统的基本架构 c语言的32个关键字 Enum: 枚举, 能穷举尽的类型。 Register: 修饰一个变量, 让这个变量直接存到寄存器里面。 signed: 表示有符号 unsigned: 无符号 void: 表示空类型 9 种控制语句: 34中预算符号: 1 #include <stdio
阅读全文