当前位置:网站首页>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 ).
边栏推荐
- My touch screen production "brief history" 2
- Easy touch plug-in
- vcs import src < ros2. Repos failed
- Map的实现类的顺序性
- Client server model
- P1896 [scoi2005] non aggression (shape pressure DP)
- Unity2019_ Lighting system
- RM delete file
- PIP uses image website to solve the problem of slow network speed
- Delete the last character of the string in golang
猜你喜欢

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

Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does

Youyou1 of xlua knapsack system

Unity performance optimization

C language - Introduction - essence Edition - take you into programming (I)
![[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)](/img/de/1c75b5e7ed79aca47462de365428a7.jpg)
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)

数据的存储

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

Transplantation of freetype Library

Abstract classes and interfaces
随机推荐
Unity dotween sequence animation replay problem.
Golang time format sorting
Scite change background color
P1896 [SCOI2005] 互不侵犯(状压dp)
jsutlis
Compilation error: "not in executable format: file format not recognized"“
MXone Pro自适应2.0影视模板西瓜视频主题苹果cmsV10模板
My touch screen production "brief history" 2
Golang中删除字符串的最后一个字符
Editor Extensions
An intern's journey to cnosdb
Shader foundation 01
How to configure GDAL under idea
Abstract classes and interfaces
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
什麼是定義?什麼是聲明?它們有何區別?
Usage of (case, when) in PostgreSQL
Basic operation and process control
Base64编码简介
[usaco12mar]cows in a skyscraper g (state compression DP)