You need to review how
printf()
is used:
printf, fprintf, sprintf, snprintf, printf_s, fprintf_s, sprintf_s, snprintf_s - cppreference.com[
^]
In general printf() looks like
int printf(const char *format_string, arg1, arg2, ...);
Where
format_string describes the other arguments. So for example a format string of
"%d"
will treat the next argument as a integer, regardless of what it actually is. It is up to
you, as the programmer to get things right. Fortunately, these days compilers are "printf aware" and can usually spot a problem and issue warnings as needed.
In your case you have
int *ptr;
printf(*ptr);
The warning you are getting is telling you that you are trying to convert the value of
*ptr
, which is an int with value 10 to a pointer type (char *), so its as if you wrote
printf(10)
10
is
not a character string, so the compiler is letting you know that something is not right.