当前位置:网站首页>Lesson 4 knowledge summary
Lesson 4 knowledge summary
2022-07-05 15:26:00 【Houli crab 670】
define Define constants and macros
define Define constants
define Define constants , Constant here refers to literal constant , Any constant can be defined , Such as :
#include <stdio.h>
#define MAX 25000
#define STR "Hello,CSDN"
Like the above two , Can be successfully compiled , Of course , There are other definitions , Not one by one .
define Defining macro
Such as :
#include <stdio.h>
#define MAX(x,y) ((x)>(y)?(X):(Y));
It is equivalent to
MAX (int x,int y){
int z=0;
z=((x)>(y)?(x):(y));
return z;
}
therefore define Defining macros is a little different from functions , This one has no return type , also "x","y" There is no description of the type of . Of course define There are many other ways to define macros , Here's just a brief look at .
The pointer
Speaking of pointers , Most people think this is a difficult thing to overcome , But actually , It's not as hard as rumors say , It's all rumors .
Pointer it is related to memory , Learn about memory , Pointers can be better understood .
It's in the computer ( With 32 Position as an example ), A memory unit is a byte , Similarly, a memory unit has an address .( Here is why a memory unit is not a bit ,kb,mb, But a simple explanation of a byte )
For example, define a char a=‘b’, as everyone knows a The memory occupied is one byte ( The previous articles mentioned , what Int,long All the memory occupied by ), And a byte is 8bit, So if a memory unit is one bit , Then a character variable needs 8 A bit ( Address ), An integer variable requires 4 Bytes , That is to say 32 The bit ( Address ), This pair of address numbers will waste a lot . alike , A memory unit is 1kb,1mb It's too big , So a memory unit is a byte .
There are two ways to define pointers
- int* p=a, It represents a pointer that defines an integer variable p, What's in it is a The address of
int a=9;int* p;*p=&a;It means the same as the above
ad locum*yes :*Dereference operator , It means through p Find the address stored inside p Point to
The size of the pointer variable
stay 32 The result of running in the bit platform is 4, stay 64 The result of bit platform operation is 8

The reason for the difference
First map
This is a 32 Platform , stay 32 Bit platform , An address is made up of 32 individual 2 Base numbers make up (8 individual 16 Base number ), And one 2 Hexadecimal number is 1bit, So an address takes up 4 Bytes (32bit=4byte)
Also in 64 In the platform , An address is made up of 64 individual 2 Base numbers make up , So an address takes up 8 Bytes (64bit=8byte)
Here the simple understanding of pointer is over
Structure
- Its use
Upper figure
The method used is the same as above , Just a little understanding , If you need to explain it in detail, I will talk about it after the following article . - Two output methods of structure
The first one is :
The second kind :
The second is output by function , It's not what I think , So I'm not familiar with the second one , So I didn't elaborate - Two methods of pointing to the structure
This is the function point
student1.name
This is a common point
- Enter structure data

Just a quick explanation , Because it's an array name , So the top name,sex,hometown Didn't take the address ( Because the array name is the address ), And integer needs to take the address ( Self understanding )
边栏推荐
- Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
- go学习 ------jwt的相关知识
- Easyocr character recognition
- Crud de MySQL
- F. Weights assignment for tree edges problem solving Report
- Thymeleaf uses background custom tool classes to process text
- 社区团购撤城“后遗症”
- 爱可可AI前沿推介(7.5)
- Does maxcompute have SQL that can query the current storage capacity (KB) of the table?
- String modification problem solving Report
猜你喜欢

JS knowledge points-01

Select sort and bubble sort

Fr exercise topic --- comprehensive question
![P6183 [USACO10MAR] The Rock Game S](/img/f4/d8c8763c27385d759d117b515fbf0f.png)
P6183 [USACO10MAR] The Rock Game S

Bubble sort, insert sort
![1330: [example 8.3] minimum steps](/img/69/9cb13ac4f47979b498fa2254894ed1.gif)
1330: [example 8.3] minimum steps

做研究无人咨询、与学生不交心,UNC助理教授两年教职挣扎史

把 ”中台“ 的思想迁移到代码中去

B站做短视频,学抖音死,学YouTube生?

Thymeleaf uses background custom tool classes to process text
随机推荐
mapper.xml文件中的注释
queryRunner. Query method
Cartoon: programmers don't repair computers!
Cartoon: what are the attributes of a good programmer?
Bugku's Ping
百亿按摩仪蓝海,难出巨头
MySQL5.7的JSON基本操作
Fr exercise topic --- comprehensive question
Bugku easy_ nbt
Magic methods and usage in PHP (PHP interview theory questions)
Machine learning notes - gray wolf optimization
Reasons and solutions for redis cache penetration and cache avalanche
sql server学习笔记
mapper. Comments in XML files
Bubble sort, insert sort
Usage and usage instructions of JDBC connection pool
爱可可AI前沿推介(7.5)
lv_ font_ Conv offline conversion
CODING DevSecOps 助力金融企业跑出数字加速度
ionic cordova项目修改插件