Re:Ask HN: An Advanced C Tutorial
by pietrofmaggi on Friday July 16, 2010 @03:58PM
(#1522333)
One interesting usage of sizeof() is to calculate the dimension of an array at compile time:
and this is handy for static arrays with dimension defined by its data, likes:
When you add a new array elements, it just keep the stuffs going calculating it at any recompilation:
Another useful macro to work with structs is offsetof(), its incredibly usefull when you have to port some code to different compilers/target with different alignments and paddings.
[ Parent
| on HN ]
There are no comments on this comment yet.