I am a first year student in C programming so my skill/knowledge is limited. I am trying to create my own implementation on printf
, but I am having trouble with retrieving and printing the address of a variable. With printf
, its possible to output the address of a variable with %p
, i need to replicate %p
somehow.
When storing the address of a variable, the data type is int*
, and I cannot figure out how to write this address to the screen(stdout).
For Example:
int i = 123;
int *address = &i;
Now how would I output address
(not the value at i
)? I have tried using the original printf
format specifiers for testing purposes. I tried using %x, %s, %d, %lu... it all gives me an error as I am trying to output an int*
(integer pointer).
Can anyone assist me in outputting the address?