如何在C编程语言手动分配指针地址? [英] How to assign pointer address manually in C programming language?
本文介绍了如何在C编程语言手动分配指针地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何用C编程语言手动分配指针地址?
例如内存地址是0x28ff44
How to assign pointer address manually in C programming language? for example memory address is 0x28ff44
推荐答案
这样的:
void * p = (void *)0x28ff44;
或者,如果你想把它当作一个的char *
:
char * p = (char *)0x28ff44;
...等。
如果你指着东西,你真的,真的不是为了改变,添加一个常量
:
If you're pointing to something you really, really aren't meant to change, add a const
:
const void * p = (const void *)0x28ff44;
const char * p = (const char *)0x28ff44;
...因为我想这一定是某种著名地址和那些通常(尽管总是没有办法)只读的。
...since I figure this must be some kind of "well-known address" and those are typically (though by no means always) read-only.
这篇关于如何在C编程语言手动分配指针地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文