sizeof error - Raspberry Pi Forums


so, signed cs50x, , it's going well, no major problems, however... have sample code them finds size of... something... don't understand yet, post code , error i'm getting.

though want not have problem, want find out why there problem in firstplace.

code: select all

#include <stdio.h>  int main(void) {     char c;     double d;     float f;     int i;          printf("char: %i\n", sizeof(c));     printf("double: %i\n", sizeof(d));     printf("float: %i\n", sizeof(f));     printf("int: %i\n", sizeof(i)); }
error get...:
clang -ggdb3 -o0 -std=c11 -wall -werror sizeof.c -lcs50 -lm -o sizeof
sizeof.c:11:26: error: format specifies type 'int' argument has type 'unsigned long' [-werror,-wformat]
printf("char: %i\n", sizeof(c));
~~ ^~~~~~~~~
%lu
sizeof.c:12:28: error: format specifies type 'int' argument has type 'unsigned long' [-werror,-wformat]
printf("double: %i\n", sizeof(d));
~~ ^~~~~~~~~
%lu
sizeof.c:13:27: error: format specifies type 'int' argument has type 'unsigned long' [-werror,-wformat]
printf("float: %i\n", sizeof(f));
~~ ^~~~~~~~~
%lu
sizeof.c:14:25: error: format specifies type 'int' argument has type 'unsigned long' [-werror,-wformat]
printf("int: %i\n", sizeof(i));
~~ ^~~~~~~~~
%lu
4 errors generated.
make: *** [sizeof] error 1

if little help, amazing. thank you.

your printf statement using %i format specifier.
sizeof() returns unsigned long, should use %ld instead.


raspberrypi



Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code