当前位置:网站首页>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 )
边栏推荐
- I collect multiple Oracle tables at the same time. After collecting for a while, I will report that Oracle's OGA memory is exceeded. Have you encountered it?
- Talk about your understanding of microservices (PHP interview theory question)
- [recruitment position] Software Engineer (full stack) - public safety direction
- How to paste the contents copied by the computer into mobaxterm? How to copy and paste
- 市值蒸发超百亿美元,“全球IoT云平台第一股”赴港求生
- Redis distributed lock principle and its implementation with PHP (2)
- mapper.xml文件中的注释
- Can gbase 8A view the location of SQL statement history?
- ICML 2022 | explore the best architecture and training method of language model
- 机器学习笔记 - 灰狼优化
猜你喜欢
NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
Huiyuan, 30, is going to have a new owner
Mysql---- function
Database learning - Database Security
lvgl 显示图片示例
Ctfshow web entry information collection
Huawei Hubble incarnation hard technology IPO harvester
【jvm】运算指令
Bugku easy_ nbt
Common PHP interview questions (1) (written PHP interview questions)
随机推荐
I include of spring and Autumn
F. Weights assignment for tree edges problem solving Report
12 MySQL interview questions that you must chew through to enter Alibaba
Can gbase 8A view the location of SQL statement history?
Number protection AXB function! (essence)
[JVM] operation instruction
episodic和batch的定义
easyOCR 字符識別
wxml2canvas
Easyocr character recognition
Bugku easy_ nbt
你童年的快乐,都是被它承包了
JMeter performance test: serveragent resource monitoring
华为哈勃化身硬科技IPO收割机
Huiyuan, 30, is going to have a new owner
Hongmeng system -- Analysis from the perspective of business
Example of lvgl display picture
P6183 [USACO10MAR] The Rock Game S
机器学习框架简述
Go learning ----- relevant knowledge of JWT