int num = *(int *)number;这是做什么的? [英] int num = *(int *)number; What does this do?

查看:53
本文介绍了int num = *(int *)number;这是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在看一些c ++代码,并且看到了:

I was looking at some c++ code, and I saw this:

int num = *(int *)number;

我以前从未见过?它在一个这样标记的函数中:

I had never seen this before? it was in a function labeled as such:

void *customer(void *number){ }

那还能做什么?有其他显示方式吗?

What does that even do? Is there a different way to show this?

谢谢,这不是功课,但我只是对它的作用感到困惑?

Thanks, this isn't homework btw I was just confused at what this does?

推荐答案

(int *)部分将变量号强制转换为指向int的指针,然后前面的*将其取消引用为int.

The (int *) part casts the variable number to a pointer to an int, then the * in front dereferences it to an int.

这篇关于int num = *(int *)number;这是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆