Gopinath Gopinath - 1 month ago 18
C Question

Can we assign a value to a given memory location?

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)
{

}

Answer

The answer depends on some factors. Is your program running within a modern operating system?

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.

Comments