gpt4 book ai didi

c - 指针地址内存属于RAM还是Hard Drive?

转载 作者:太空宇宙 更新时间:2023-11-04 05:12:00 24 4
gpt4 key购买 nike

#include <stdio.h>
int main() {
int num=1234;
printf("%p", &num);
return 0;
}

//Ouput:
//0xffffcbfc

0xffffcbfc 是 RAM 还是硬盘地址内存?

最佳答案

严格来说,该代码表现出未定义的行为。您必须将指针转换为 void *,因为这是 %p 所期望的:

printf("%p\n", (void *) &num);

从 C 的角度来看,可能并没有具体说明保存地址的物理设备类型,但在典型的计算机上,它将是 RAM。

关于c - 指针地址内存属于RAM还是Hard Drive?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46465594/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com