当前位置:网站首页>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 ).
边栏推荐
- Maxcompute string splitting function -split_ PART
- C language learning notes (mind map)
- Install cross compiler arm none liunx gnueabihf
- About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed
- idea取消引用显示效果
- 璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型
- the installer has encountered an unexpected error installing this package
- 数据分析练习题
- Three characteristics
- MXone Pro自适应2.0影视模板西瓜视频主题苹果cmsV10模板
猜你喜欢

Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données

A tunnel to all ports of the server

数据库应用技术课程设计之商城管理系统

How to establish rectangular coordinate system in space

Lua framwrok framework starts

C语言-入门-精华版-带你走进编程(一)

Get to know unity2 for the first time

JS common basic case sorting (continuous update)

Pulitzer Prize in the field of information graphics - malofiej Award

Unity2019_ Natural ambient light_ Sky box
随机推荐
Haproxy+kept cluster setup 02
JS regular case-
ArrayList
JS to implement publish and subscribe
the installer has encountered an unexpected error installing this package
Editor Extensions
Flex flexible box layout
Golang 字符串分割,替换和截取
Golang string segmentation, substitution and interception
Clip Related Script
CLion-Toolchains are not configured Configure Disable profile问题解决
Quelle est la définition? Qu'est - ce qu'une déclaration? Quelle est la différence?
IP production stream is so close to me
Pulitzer Prize in the field of information graphics - malofiej Award
[end of 2021] National Meteorological Short Video (Kwai, Tiktok) influence list in December
Generate video using clipout in viz engine
regular expression
方正锐利重磅升级到12.0版本,包装印前处理更加便捷、高效!
Scite change background color
Ilruntime learning - start from scratch