I was doing some C coding and after reading some C code I\'ve noticed that there are code snippets like
char *foo = (char *)malloc(sizeof(char) * someDynamicAmo
You're correct, by standard, the multiplication is irrelivant. That said, it looks like a habit someone got into to be consistent. If you always use the sizeof()
, regardless of type, you never forget.
char *foo = (char *)malloc(sizeof(char) * someDynamicAmount);
int *bar = (int *)malloc(sizeof(int) * someDynamicAmount);