小编VM *_*ova的帖子

C为什么void指针不能存储浮点值?

我正在尝试返回浮点值但是当我打印出来时,我得到0.0.

float floating = 4.5;

void* function(){
    void* test = &floating;
    return test;
}

int _tmain(int argc, _TCHAR* argv[]){
     printf("%f\n", test());
     return 0;
}
Run Code Online (Sandbox Code Playgroud)

关于它为什么不打印4.5的任何想法?对不起,如果这是一个菜鸟问题,我还是比较新的.

c pointers

3
推荐指数
3
解决办法
1742
查看次数

标签 统计

c ×1

pointers ×1