In a string table, all strings used in a structure are stored at the end of the structure in packed format. The structure includes fields that specify the offsets from the beginning of the string table to the individual strings. An example follows:
typedef struct { INT iWidgetNumber; /* the widget number */ USHORT offszWidgetName; /* an offset to a string in <rgchStrTab>*/ USHORT offszWidgetDesc; /* an offset to a string in <rgchStrTab> */ INT iQuantity; /* how many widgets */ CHAR rgchStrTab[1]; /* string table (allocate as large as needed) */ } WIDGET;
If multiple chunks within the file need to reference variable-length strings, you can store the strings in a single chunk that acts as a string table. The chunks that refer to the strings contain offsets relative to the beginning of the data part of the string table chunk.