Even though I‘m not a sheer expert on 'C' I wanted to give my nephew some beginner‘s lessons on pointer acrobatics. Therefore I needed to put an address into a string to let him read this. I studied two topics concerning ‘address to string‘:
In parts not flawlessly working
What I tried before,
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int Aa = 90;
// printf("\nAa got the address %p", &Aa); // of course working !!
printf("\nAa got the address %x", &Aa);
printf("\nAa got the value %d \n", Aa);
return 0; }
resulted in a harmless but not at all welcomed warning:
format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘int*’ [-Wformat=]
and when I chose the simple way out of what I found:
...
char strAddress[] = "0x000000000";
sprintf(strAddress, "0x%x", &Aa);
...
of course I got the same warning with ‚sprintf‘ when trying to write to a DC.
The question is: How to avoid the warning when using just c-string?