Skip to main content

c-starter

What is char?

The char datatype represents a single byte.

How can I print a char in hexadecimal?

Pass the %x formatter to printf.

How can I force printf to print two digits?

Specify a number before the formatter e.g. %2x

Compiler errors

expression preceding parentheses of apparent call must have (pointer-to-) function type

You are reassining a method or variable.

e.g. here the name of the method and the variable we are assigning are the same

SDL_Rect sprite_rect = sprite_rect(MEEPLE_SPRITE_INDEX);

argument of type "SDL_Rect" is incompatible with parameter of type "void *"

You might be calling free on the object directly. Instead you should pass a pointer to it.

// rather than
free(source_rect);
// pass the pointer
free(&source_rect);