Macros can take arguments that are replaced by the preprocessor.
#define MAX_USERS 100 #define BYTES_NEEDED(n,type) n * sizeof(type) int *scores = malloc( BYTES_NEEDED( MAX_USERS, int ) );
becomes
int *scores = malloc( 100 * sizeof(int) );TOC | Prev | Next