标题:[求助]void*的用法
只看楼主
yandongdido
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2007-9-6
 问题点数:0 回复次数:2 
[求助]void*的用法
如果声明指针是void*,它意味着任何型的地址都可以间接引用那个指针
那么,在*((int *)p)=3中是不是在把空指针改了以后,成为整形的,就一直是整形的 不能改变吗 ????
搜索更多相关主题的帖子: void 用法 
2007-09-17 22:05
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
得分:0 

void* is called the generic pointer --- every pointer is 4 bytes (32-bit os) so that you can cast between different pointer types.

*((int*)p) = 3;

only says that the content of the memory location to which p points is 3.

It does not say p is a void*, or a int*.


I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-09-17 22:29
yandongdido
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2007-9-6
得分:0 
哦好象说的有道理,那让我在仔细看看把
谢谢了!

2007-09-18 16:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-170728-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.105020 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved