I am receiving warnings when compiling my code. These warnings include: format %lu expects argument of type 'long unsigned int' but argument 3 has type long long unsigned int
& cast from printer to integer of different size
.
I don't seem to know what is wrong. Any advice on how to fix this is much appreciated.
void printBits(size_t const size, void const * const ptr);
int main()
{
// variables are not in order on purpose for the first step in running the code.
float c;
char a;
double d;
int b;
d = 561232019; /* 8 bytes */
c = 154.6; /* 4 bytes */
b = -83273; /* 4 bytes */
a = 42; /* 1 byte */
printf("\n--------------------------------------------\n");
printf("LABEL - ADDRESS(hex) ADDRESS (dec) [S - E] - BINARY\n");
printf("A - ");
printf("%p - ",&a);
printf("%lu - %lu ",(long)&a, (long)&a + sizeof(a)-1); // the two errors occur at
//this line as well as the other identical print statements for each variable used. This print
//statement is identical to when using b, c, d and all have the same warnings. I just used this part
//of code to find out how to fix this error so I could fix all the other identical print statements.
printf("%d - ",a);
printBits(sizeof(a), &a);
printf("\n--------------------------------------------\n");