3 ms·
Also, sizeof is an operator, not a function, so you can write that as long_struct_name *foo = malloc(sizeof *foo);
by decklin 15y ago
Also, sizeof is an operator, not a function, so you can write that as
long_struct_name *foo = malloc(sizeof *foo);
- tkahn6 15y agoThis is true but there is a qualifier here: If a type name is used, it always needs to be enclosed in parentheses, whereas variable names and expressions can be specified with or without parentheses. So long_struct_name *foo = malloc(sizeof long_struct_name) won't compile.