Set the value of an integer variable with an absolute address of 0x67a9 to 0xaa66

Embedded systems often have characteristics that require programmers to access specific memory locations. In a certain project, it is required to set the value of an integer variable with an absolute address of 0x67a9 to 0xaa66. The compiler is a pure ANSI compiler. Write code to accomplish this task.

This question tests whether you know that it is legal to typecast an integer to a pointer in order to access an absolute address. How this is accomplished varies with personal style. Typical similar code is as follows:

int *ptr;
ptr = (int *)0x67a9;
*ptr = 0xaa66;

A more obscure method is:

*(int * const)(0x67a9) = 0xaa66;

Guess you like

Origin blog.csdn.net/lijunlin0329/article/details/129044304