Hacker News new | past | comments | ask | show | jobs | submit login

Also, sizeof is an operator, not a function, so you can write that as

    long_struct_name *foo = malloc(sizeof *foo);



This 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: