当前位置:网站首页>Why can void * be a general pointer
Why can void * be a general pointer
2022-07-03 08:15:00 【The east wind blows the Willows】
First , The way void * Previous solutions :char * stay void Type acts as a general pointer before it comes out , however ASCII It specifies void keyword , Then for general pointers ,void * Instead of char *, But you can still use char * understand void * .
then , from char * Analyze... From an angle , because char It is the most basic memory unit in a computer (8 bit), So any other type is char Integer multiple , So any type of pointer is assigned to char * After that, it will be correctly truncated to the first memory address of the original type , And reinterpretation will not bring errors to the original data type .
Then come to the core principle :
(1) During the life cycle of the original pointer , Convert it to char * Belongs to equal size conversion , in other words , The size of any pointer is equal .
(2)char * What is saved is the first memory address of the original object , This value is equal to the value saved by the original pointer object .
(3) During the life cycle of the original pointer , Will be converted to char * Re convert to the original pointer object , It will still be the original .
Come to a conclusion :char * It can be used as a general pointer , void * It can be used as a general pointer .
tips: For pointer ,ANSI C The standard specifies its assignment constraints ( Include initialization ):
1. Both operands are compatible pointers to finite determiners or infinite operators ;
2. The type pointed to by the pointer to the operand must have all qualifiers of the type pointed to by the right operand pointer ( The qualifier of the left operand can be more ).
边栏推荐
- 璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型
- idea取消引用顯示效果
- C language learning notes (mind map)
- Youyou1 of xlua knapsack system
- About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed
- the installer has encountered an unexpected error installing this package
- JS regular case-
- vcs import src < ros2. Repos failed
- Yolo series --- xml2txt script
- JS common basic case sorting (continuous update)
猜你喜欢

Open the influence list of "National Meteorological Short Videos (Kwai, Tiktok) in November" in an interactive way“

Basic operation and process control

Storage of data

oracle 插入单引号

Unity2019_ Natural ambient light_ Sky box

How to establish rectangular coordinate system in space

MAE

Easy touch plug-in

Oracle insert single quotation mark

C language learning notes (mind map)
随机推荐
数据的存储
Wechat native applet cloud development learning record 01
Unity dotween sequence animation replay problem.
Golang 中string和int类型相互转换
Ilruntime learning - start from scratch
Puhua PLM empowers the whole scene product lifecycle management and helps the enterprise digital transformation of the main line of products
璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型
Compilation error: "not in executable format: file format not recognized"“
RM delete file
E: Unable to locate package ROS melody desktop full
Flex flexible box layout
haproxy+keepalived搭建01
Use filechannel to copy files
Pulitzer Prize in the field of information graphics - malofiej Award
数据库应用技术课程设计之商城管理系统
Abstract classes and interfaces
Oracle queries grouped by time
数据分析练习题
JS regular case-
CLion-Toolchains are not configured Configure Disable profile问题解决