Beginner to C, using CodeBlock now. Just want to check the bytes of memory occupied by variables in C. I wonder why this error will occur here. Thank u!
int main()
{
char ch;
short a;
int b;
long c;
float d;
double e;
ch = 'a';
a = 1;
b = 2;
c = 3;
d = 1.5;
e = 1.5;
printf ("%d\n", sizeof(char));
printf ("%d\n", sizeof(short));
printf ("%d\n", sizeof(int));
printf ("%d\n", sizeof(long));
printf ("%d\n", sizeof(float));
printf ("%d\n", sizeof(double));
return 0;
}
error shows: format '%d' expects argument of type 'int', but argument 2 has type 'long long unsigned int' [-Werror=format=]|
when changing from %d
to %zu
or %lu
, there are still errors shown:
error: unknown conversion type character 'z' in format [-Werror=format=]
error: too many arguments for format [-Werror=format-extra-args]|