#include #include #include //for offsetof using namespace std; //Assume that there is pading between fields only to satisfy the alignment //requirements. template inline size_t align() { struct s { char c; T t; }; return offsetof(s, t); } int main() { cout << "char " << align() << "\n" << "short " << align() << "\n" << "int " << align() << "\n" << "float " << align() << "\n" << "double " << align() << "\n" << "long double " << align() << "\n" << "void * " << align() << "\n"; return EXIT_SUCCESS; }