One interesting use of sizeof i remember in my C++ project was to override new and delete operators where a void pointer is passed and sizeof is used to keep track of how much memory is allocated/deallocated.
When you add a new array elements, it just keep the stuffs going calculating it at any recompilation:
for (i=0; i<dim(m_stCmdMap); i++) {
if (m_stCmdMap[i].enCommand == stCmdLocal.enCommand) {
m_stCmdMap[i].Fxn(&stCmdCopy);
break;
}
}
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.
One interesting use of sizeof i remember in my C++ project was to override new and delete operators where a void pointer is passed and sizeof is used to keep track of how much memory is allocated/deallocated.