C语言如何手动分配指针地址? [英] How to assign pointer address manually in C programming language?

查看:17
本文介绍了C语言如何手动分配指针地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 C 编程语言中手动分配指针地址(例如分配给内存地址 0x28ff44)?

How do you assign a pointer address manually (e.g. to memory address 0x28ff44) in the C programming language?

推荐答案

像这样:

void * p = (void *)0x28ff44;

或者如果你想要它作为 char *:

Or if you want it as a char *:

char * p = (char *)0x28ff44;

...等等

如果你指向的是你真的,真的不想改变的东西,添加一个const:

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屋!

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