I am attempting to get the program to compile in command line. I cannot get it t
ID: 3551586 • Letter: I
Question
I am attempting to get the program to compile in command line. I cannot get it to compile do to a warning stating that %d expects a int and is recieving a long int. How do I fix this error?
Of course this is just a warning there is no error and it will compile but how do I fix the warnings?
Trying to compile in GCC.
#include<stdio.h>
int main(void)
{
short a;
unsigned short b;
int c;
long d;
unsigned e;
unsigned long f;
float g;
char h;
double i;
printf("Size of Short Integer: %hd ", sizeof(a));
printf("Size of Unsigned Short Integer: %u ", sizeof(b));
printf("Size of Integer: %d ", sizeof(c));
printf("Size of Long Integer: %ld ", sizeof(d));
printf("Size of Unsigned Integer: %a ", sizeof(e));
printf("Size of Unsigned Long Integer: %d ", sizeof(f));
printf("Size of Float: %d ", sizeof(g));
printf("Size of Character: %d ", sizeof(h));
printf("Size of Double: %d ", sizeof(i));
return(0);
}
Explanation / Answer
I m not getting any warning for your code.It has to be system dependent feature.Which system are you using.Must be because of difference short int ,int and long int on your system.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.