c - sizeof-operator 反向行为
问题描述
我们知道,当我们使用数组时,它保存第一个元素的地址,&array 存储整个数组地址,当我在 printf 中使用它时它是正确的,但在 sizeof 运算符中它是相反的行为,为什么
我在 Windows 7 上使用带有 GCC 的代码块
int main(void)
{
int c[5];
printf(" %d %d %d %d\n",c,c+1,&c,&c+1);\\when we add 1 in "c" it add more 4 bytes and when "&c+1" it add 20 byte witch is true
printf(" %u %u ",sizeof(c),sizeof(&c));\\But when we print first element size (with "c") it give 20 byte and when print (With "&c") whole arry size it give 4 byte
return 0;
}
\我不明白为什么请解释
解决方案
推荐阅读
- angular - Angular 5:在点击事件上检测firestore文档ID
- python - 在 numpy.where 返回的数组之间查找唯一索引
- ruby-on-rails - 我无法对远程主机运行“cap XXX deploy”
- android - 颤振 - 如何打开或要求用户打开位置?
- python - 如何在 tkinter 中删除或销毁标签?
- java - 登录salesforce rest api时字符串不能转换为org.json.JSONObject
- ruby-on-rails - 使用 prawn 作为 actionmailer 附件呈现 pdf
- php - 如何防止用户使用我在 Web 应用程序中下载 pdf 文件的 PHP 下载选项下载源代码文件?
- serial-port - rs-485 USB转RS485 C码
- javers - Javers 中是否有可用的侦听器,例如 postUpdate、postCreate