I'm having a play around with an embedded dev kit, and although I know the very basics in C, I'm trying to use pointers to access a certain memory location. Specifically I want to write;
0x00000055 to memory location 0xFF003030
any suggestions;
my initial approach was;
int *ptr = 0xFF003030;
ptr = 0x00000055;
Using C how do I write to a memory location using pointers?
int *ptr; /* declare the poiner to an integer at first */
ptr=0xFF003030; /* let the programm know that location's address*/
*ptr=0x00000055; /* put the desired value to the previously setted location */
(PS: AM is Wrong! His solution is to put a value in a place the compiler will choose, which doesn't solve the proposed problem; my solution does; and it's the shortest!)
Reply:Well mate, u makin 1 mistake i suppose...instead of *ptr(i.e. a pointer) try using a variable like int ptr=0xFF003030 since hexadecimal numbers are assigned in this way and its just a hexadecimal value not a reference......
flowers on line
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment