'warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [closed]
I have this program that claims to convert a decimal number to hexadecimal. The issue is that the program throws the above warning and I don't know how to correct it. The return (variable identifier) is supposed to be a %s because what you want to display is a string.
#include <stdio.h>
int main() {
int n = 0;
char hex = '\0';
const char * HEX_DIG = "0123456789ABCDEF";
printf ("Enter a positive integer: ");
scanf ("%d",&n);
do{
hex = HEX_DIG [n % 16] + hex;
n = (int) n/16;
}while ( n != 0 );
printf ("\nHexadecimal= %s", hex);
return 0;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
