当前位置:网站首页>Void* pointer
Void* pointer
2022-06-13 08:54:00 【Human high quality Algorithm Engineer】
You can see in the code (void )stDst.pucBuf The pointer , void What is the pointer for , See below ,
void Literally, it means “ No type ”,void * Then for “ No type pointer ”,*void Can point to any type of data .( The key )
Any type of pointer can be assigned directly to void*, There is no need to cast
void *p1;
int *p2;
p1 = p2;
void *arg;
int i;
i=(int *)arg;
If you define void type :
void a;
This line will compile with an error , Even if void a There will be no errors in the compilation of , It doesn't have any practical significance either .
void It's just an abstract need , If you understand object-oriented correctly “ Abstract base class ” The concept of , And it's easy to understand void data type . Just as you can't define an instance of an abstract base class , We can't define a void Variable .
void The rules of using keywords :
1. If the function does not return a value , Then it should be declared as void type ;
2. If the function has no arguments , Then it should be declared that the parameter is void;
3. If the argument to a function can be a pointer of any type , Then it should be declared that the parameter is void * ;
4. void Can't represent a real variable ;
Here's the explanation :
void The real role is :
(1) A restriction on the return of a function ;
(2) Restrictions on function parameters .
1. If the function does not return a value , Then it should be declared as void type ;
stay C In language , Any function without return value type restriction , Will be handled by the compiler as a return integer value . But many programmers mistake it for void type . for example :
add ( int a, int b )
{
return a + b;
} // The return is int type
Of course we're writing C/C++ The program , For any function, its type must be specified one by one . If the function does not return a value , Be sure to state that void class
type . This is the need for good readability of the program , It is also the requirement of programming standardization .
2. Careful use void Pointer types
according to ANSI(American National Standards Institute) standard , Not right void Pointer for algorithm operation , The following operations are illegal :
void * pvoid;
pvoid++; //ANSI: error
pvoid += 1; //ANSI: error
//ANSI The reason why the standard is so recognized , It's because it insists on : The pointer for algorithm operation must be determined to know the size of the data type it points to .
// for example :
int *pint;
pint++; //ANSI: correct
边栏推荐
- JS ask for the day of the year
- Problèmes et traitement du disque gbase 8a
- Container concept and cloud native
- I set up a blog
- Bash: kill: (74001) - operation not allowed
- 1、 JS introduction
- How to save the video of wechat video number locally?
- How does jupyter notebook directly output the values of multiple variables after running?
- 容器概念和云原生
- 「解读」华为云桌面说“流畅”的时候,究竟在说什么?
猜你喜欢

5. Attribute selector

Installing pytorch under Anaconda

【网络安全】SQL注入新思维之webshell提权

A solution to create a new EXCEL workbook on win10 computer and change the suffix to xlsm (normally it should be xlsx)

4. Relationship selector (parent-child relationship, ancestor offspring relationship, brother relationship)
![WARNING:tornado.access:404 GET /favicon.ico (172.16.8.1) 1.84ms [附静态文件设置]](/img/6d/6eef1f0ebcab45e9a209a3b6c62b03.png)
WARNING:tornado.access:404 GET /favicon.ico (172.16.8.1) 1.84ms [附静态文件设置]

Screenshot of cesium implementation scenario

1.SolidWorks各模块的学习顺序

Print an array clockwise

Svg text stroke effect
随机推荐
File upload JS
Mapbox usage, including drawing, loading, modifying, deleting points and faces, displaying pop ups, etc
output. Interpretation of topk() function
redis
JS wrapper object
Docker installing MySQL local remote connection docker container MySQL
顺时针打印个数组
Time and date processing in JS
1. Learning sequence of SolidWorks modules
Paging query template of Oracle
Yarn package management tool
Installing pytorch under Anaconda
Object in ES6 Use of entries()
2020-12-28
5、 Constant, variable
Review one flex knowledge point every day
[pychart pit stepping record] prompt after configuring remote operation, [errno 2] no such file or directory
Differences among let, VaR and const when JS declares variables
Three methods to make the scroll bar of div automatically scroll to the bottom
13.inline,const,mutable,this,static