当前位置:网站首页>C language learning record 6
C language learning record 6
2022-06-11 13:39:00 【byte02】
The pointer
We know that the purpose of variable definition is to apply for space from memory to store variables , So how to find out where the variable is ? answer : Through the address , Memory instances also have addresses , Like we live in different places , Such as : Bedroom address , School address ..., The same memory has addresses .
Pointer variables are variables used to store addresses .
example :
Type identifier * Variable name (int * pa;float* pb;);
"*" Indicates that the variable is of pointer type , Type identifier (int ,float,char) Represents the type of the variable that the pointer points to
The size of the pointer variable is 4 Bytes (32 Bit platform )/8 Bytes (64 Bit platform )
example :
...
int
a
=
10;
int
*
pa
=
&
a;
//&a Take out a The address of variables in memory is stored in pa In this pointer variable
*
pa;
// adopt “*” Operators can access variables indirectly a
...
- 1.
- 2.
- 3.
- 4.
- 5.
Structure
Used to describe the type of a complex object , This type is created by the developer
example :
...
struct
stu
{
char
name[
30];
int
age;
char
sex[
10];
...
};
// Semicolon with table structure type ends
...
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
Use keywords as above struct Created a stu The type of
How to use this type and access its members ?
...
struct
stu
{
char
name[
20];
int
age;
char
sex[
10];
};
int
main()
{
struct
stu
s1
={
" Zhang San "
,20,
" male "}
// Use structure type stu establish s1 The structural variable of
s1.
name;
// adopt “.” Operator to access structure member variables
return
0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
Structure pointer variable and variable access
...
struct
stu
{
char
name[
20];
int
age;
char
sex[
10];
};
int
main()
{
struct
stu
s1
={
" Zhang San "
,20,
" male "}
// Use structure type stu establish s1 The structural variable of
s1.
name;
// adopt “.” Operator to access structure member variables
struct
stu
*
ps
=
&
s1;
// Change the structure variable s1 The address of is fetched and stored in the structure pointer variable ps in
(
*
ps).
name;
// Or through “*” Operator to introduce access , But unlike before, you need parentheses “()” Cover up . But it seems inconvenient , It's not convenient to write
ps
->
name;
// adopt "->" Operator to access structure variable members , This kind of writing is concise and clear
return
0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
notes :“.” And “->” difference “.” Applied to structural variables ,“->” Applied to structure pointer variables
边栏推荐
- Introduction to reverse learning - excellent assembly debugging tool OllyDbg
- vim二次替换
- 可变参表达式
- XXVIII - 3D point cloud real-time and offline generation of 2D grid and 3D grid map
- The tree (AVL, 2-3-, red black, Huffman)
- C # set the cursor shape of forms and systems
- Explain in detail the differences between real participation formal parameters in C language
- 三级分类展示
- 使用华为HECS云服务器打造Telegraf+Influxdb+Grafana 监控系统【华为云至简致远】
- 深度学习与CV教程(14) | 图像分割 (FCN,SegNet,U-Net,PSPNet,DeepLab,RefineNet)
猜你喜欢

AGV机器人RFID传感器CK-G06A与西门子1200PLC应用手册

cadence SPB17.4 - allegro - allegro_ free_ viewer

关于分布式锁的续命问题——基于Redis实现的分布式锁

Can't understand kotlin source code? Starting with the contracts function~

Two small things, feel the gap with the great God

LNMP deployment

Please, don't use enumeration types in external interfaces any more!

Energy storage operation and configuration analysis of high proportion wind power system (realized by Matlab)

Bs-xx-007 registered residence management system based on JSP

折叠表达式
随机推荐
On software defects and loopholes
RS485(Modbus RTU)工业RFID读写器CK-FR03-A01与PLC三菱FX5U的通讯操作说明
create_ Error in engine MySQL connector encryption method
六.开发记录之实验室服务器LXD部署
About PHP: the original deployment environment written by PHP is deployed in phpstudy, PHP + MySQL + Apache. However, the computer must be turned on every time
面试造航母,入职拧螺丝,工资...
cadence SPB17.4 - allegro - allegro_free_viewer
Terraform + Ansible实现基础设施及配置管理
关于分布式锁的续命问题——基于Redis实现的分布式锁
Collapse expression
高比例风电电力系统储能运行及配置分析(Matlab实现)
Add environment path
InfoQ geek media's 15th anniversary essay solicitation - dynamic ranking of mobile terminal development [mui+flask+mongodb]
AGV robot RFID sensor ck-g06a and Siemens 1200plc Application Manual
kubernetes 证书合集
ecplise无法连接sql server
长连接简介
代码对比工具,我就用这6个
The tree (AVL, 2-3-, red black, Huffman)
【信号去噪】基于稀疏性 (BEADS) 实现色谱基线估计和去噪附matlab代码和论文