当前位置:网站首页>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 ).
边栏推荐
- KunlunBase MeetUP 等您来!
- 链式长取值
- Golang time format sorting
- Conversion between JSON and object
- C#课程设计之学生教务管理系统
- Dotween plug-in
- Unity one click AssetBundle
- One dimensional array two dimensional array (sort Max insert sort)
- P2704 [noi2001] artillery position (shape pressure DP)
- I want to do large screen data visualization application feature analysis
猜你喜欢
Multi traveling salesman problem -- overview of formula and solution process
数据库应用技术课程设计之商城管理系统
*p++、*++p、++*p、(*p)++
Editor Extensions
the installer has encountered an unexpected error installing this package
the installer has encountered an unexpected error installing this package
Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
数据分析练习题
Wpf: solve the problem that materialdesign:dialoghost cannot be closed
一条通往服务器所有端口的隧道
随机推荐
vcs import src < ros2. Repos failed
freetype库的移植
[untitled]
Wechat applet taro learning record
the installer has encountered an unexpected error installing this package
Are you still watching the weather forecast on TV?
Golang's range
Oracle insert single quotation mark
P2704 [NOI2001] 炮兵阵地(状压dp)
Base64和Base64URL
Unity change default editor
P2704 [noi2001] artillery position (shape pressure DP)
tslib库的移植
JS to implement publish and subscribe
[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel
Transfinite hacker cognition
An intern's journey to cnosdb
C#课程设计之学生教务管理系统
What does (+) in Oracle mean
Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données