当前位置:网站首页>C语言知识点(二)
C语言知识点(二)
2022-07-31 05:18:00 【Awake1234】
基本内置类型
1.整型:带符号的整型(int),带符号短整型(short int)
长整型(long int),unsigned int(无符号整型) unsigned short int(无符号短整型) unsigned long(无符号长整型)
2.void:可以表示没有数据,也可以表示某种任意类型的数据
3.static 修饰变量,该变量空间独立于函数中的auto变量或者栈变量
static变量空间在内存中的静态区内分配
4.extern 变量名 在任何函数体外声明或定义变量时,不加extern可能是定义也可能是声明,但加extern肯定是声明
5.auto 变量:意味着当前变量的作用域为当前函数或代码段的局部变量
6.栈:有的编译器为了提高效率,出栈时不会进行数据清空
7.register:变量的值通常保存在内存中,cpu对变量进行读取先将变量的值从内存读到寄存器中然后进行运算,运算后将结果返回到内存中
(注意:1寄存器变量是单个变量,变量长度应该小于等于寄存器长度
2不能对寄存器变量使用&,因为该变量没有内存地址
3尽量在大量频繁操作时使用寄存器变量,且声明的变量个数应该尽量少)
8.volite类型的变量不管其值有没有变化,每次对其值进行访问时,都会从内存里寄存器里读取,从而能保证数据的一致,做到表里如一
9.typedef:关键字
10.typedef 与#define的比较:
typedef char * p_str1;
#define p_str2 char *;
p_str1 s1,s2;
p_str2 s3,s4;
解析:s1,s2,s3被定义为char *,s4被定义为char,因为#define只是简单的字符串替换,而typedef则是为一个类型起新名字
11.枚举
enum color
{
GREEN = 1,
RED, //red = 2
BLUE, //blue = 3
GREEN_RED = 10,
GREEN = BLUE
}colorval
注:如果常量没有被赋值则从被赋值的常量开始一次加1,如果都没有被赋值,则从0开始依次加1
12.联合体(union):各成员共享一段内存空间,一个联合变量的长度等于各成员中最长的长度,每次有效的成员只有一种
当多个数据类型或符合数据结构要占用同一片内存时我们要使用联合体,当多种数据类型,多个对象,多个事物只取其一时,我们也可以使用联合体来发挥其长处
边栏推荐
- Chemical Reagent Phospholipid-Polyethylene Glycol-Amino, DSPE-PEG-amine, CAS: 474922-26-4
- The array technique, my love
- Cholesterol-PEG-Azide CLS-PEG-N3 Cholesterol-PEG-Azide MW:3400
- 日志jar包冲突,及其解决方法
- Attention based ASR(LAS)
- 多线程截取视频为每帧
- [Solved] ssh connection report: Bad owner or permissions on C:\\Users/XXX/.ssh/config
- Log jar package conflict, and its solution
- Detailed explanation of mysql transaction principle
- Learning and understanding of ROS service programming
猜你喜欢

Pytorch Daily Practice - Predicting Surviving Passengers on the Titanic

Pytorch study notes 10 - detailed explanation of convolutional neural network and application of multi-classification task of mnist dataset

PyTorch Study Notes 08 - Loading Datasets

Remote file xxx is mapped to the local path xxx and can‘t be found. You can continue debugging....

国际站卖家大促攻略,只需要做好这几件事

MySQL master-slave switching steps

超详细!!!让你了解冒泡排序的底层逻辑和思想

Fluorescein-PEG-DSPE Phospholipid-Polyethylene Glycol-Fluorescein Fluorescent Phospholipid PEG Derivatives

mPEG-DMPE Methoxy-polyethylene glycol-bismyristyl phosphatidylethanolamine for stealth liposome formation

IDEA overview and installation and debugging
随机推荐
这些数组技巧,我爱了
Cholesterol-PEG-NHS NHS-PEG-CLS 胆固醇-聚乙二醇-活性酯可修饰小分子材料
CAS:474922-22-0 Maleimide-PEG-DSPE 磷脂-聚乙二醇-马来酰亚胺简述
UR3机器人运动学分析之逆运动学分析
Cholesterol-PEG-Azide CLS-PEG-N3 胆固醇-聚乙二醇-叠氮 MW:3400
超详细!!!让你了解冒泡排序的底层逻辑和思想
堆和栈的区别
Getting Started with MySQL: The Case Statement Works Well
【Rhapsody学习笔记】1:Hello World
Cholesterol-PEG-DBCO 胆固醇-聚乙二醇-二苯基环辛炔化学试剂
2022 SQL big factory high-frequency practical interview questions (detailed analysis)
Unity转微信小游戏与JS交互
vs2022 xlua 集成第三方库编译报错Generator Visual Studio 15 2017 could not find any instance of Visual Studio.
Attention based ASR(LAS)
Cholesterol-PEG-DBCO Cholesterol-Polyethylene Glycol-Diphenylcyclooctyne Chemical Reagent
IDEA控制台不能输入信息的解决方法
ImportError: cannot import name ‘Xxxx‘ from partially initialized module ‘xx.xx.xx‘
Pytorch study notes 13 - Basic_RNN
The content of the wangeditor editor is transferred to the background server for storage
会话和饼干,令牌