Quote Originally Posted by john.c View Post
There's no reason to pad lastname to 16 since firstName, a char array, can start on any byte.
It's more likely that firstName is padded to 13 so that balance is on an 8-byte boundary.
Yes, I can confirm that is of course true...

Code:
#include <stdio.h>
#include <stddef.h>


struct clientData {
  unsigned int acctNum; // account number    4 bytes   no padding
  char lastName[15]; // account last name   15 bytes.  padded to 16
  char firstName[10]; // account first name  10 bytes, padded to 12
  double balance; // account balance          8 bytes, no padding
};


int main(int argc, char *argv[]) {
   printf("acctNum   %zi\n", offsetof(struct clientData, acctNum));
   printf("lastName  %zi\n", offsetof(struct clientData, lastName));
   printf("firstName %zi\n", offsetof(struct clientData, firstName));
   printf("balance   %zi\n", offsetof(struct clientData, balance));
   return 0;
}
So here are the offsets in bytes from the start of the structure....

Code:
$ ./pad
acctNum   0
lastName  4
firstName 19
balance   32