Why write `sizeof(char)` if char is 1 by standard?

The more Cish way would be

char* foo = malloc(someDynamicAmount * sizeof *foo);

referencing the variable and not the type so that the type isn't needed. And without casting the result of malloc (which is C++ish).


I do sizeof(char) to make the intentions clear. If anyone ever decides he wants foo to be an int he knows he'll need to do sizeof(int) for it to keep on working.

or omit it and use the number

Plus it's not very good coding practice to use magic numbers.