我们可以将值分配给给定的存储位置吗? [英] Can we assign a value to a given memory location?
本文介绍了我们可以将值分配给给定的存储位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为存储位置(例如0X12AED567)分配一些值(例如2345).能做到吗?
I want to assign some value (say 2345) to a memory location(say 0X12AED567). Can this be done?
换句话说,我该如何实现以下功能?
In other words, how can I implement the following function?
void AssignValToPointer(uint32_t pointer, int value)
{
}
推荐答案
答案取决于某些因素.您的程序是否在现代操作系统中运行?
The answer depends on some factors. Is your program running within a modern operating system?
如果是,尝试访问未映射的内存区域将导致SIGSEGV
.为此,您必须使用系统特定的功能来映射包含此确切地址的内存区域,然后再尝试访问它.
If yes, trying to access a memory area that is not mapped will cause a SIGSEGV
. To accomplish that, you have to use a system specific function to map the region of memory that contains this exact address before trying to access it.
这篇关于我们可以将值分配给给定的存储位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文