A Str255 is a fixed size field of 256 bytes. The string inside the Str255 is variable length but a Str255 is not variable length.
TheRest could be up to 64K since the length for the comment is two bytes. I think in C you would define it like this:
char theRest[];
or this (if the compiler doesn't like flexible arrays):
char theRest[0];
or this (if the compiler doesn't like zero sized arrays):
char theRest[1];
With an array size of 1, You would have to use sizeof(CKIDRec) - sizeof(CKIDRec.theRest) to calculate the size of the non-string data.
Or use offsetof(CKIDRec, theRest) to calculate the size of the non-string data.
If the compiler doesn't have offsetof, then #define it.
https://en.wikipedia.org/wiki/OffsetofIf the data is in a locked resource, then you don't need to copy it to a local or global variable.
HLock(ResHandle);
CKIDPtr ckid = *(CKIDHandle)ResHandle;
char* p = &ckid->theRest;
char* projectPath = p; p += *p + 2;
char* userName = p; p += *p + 2;
char* revisionNum = p; p += *p + 2;
char* fileName = p; p += *p + 2;
char* taskDesc = p; p += *p + 2;
char* comment = p; p += *(unsigned short *)p + 3;
long size = p - (char*)ckid;
printf("size:%ld handlesize:%ld\n", size, GetHandleSize(ResHandle));
printf("username:\"%s\"\n", username+1);
printf("revisionNum:\"%s\"\n", revisionNum+1);
printf("fileName:\"%s\"\n", fileName+1);
printf("taskDesc:\"%s\"\n", taskDesc+1);
printf("comment:\"%s\"\n", comment+2);
A char pointer is defined for each string. Since the strings have one or two size bytes, you need to add 1 or 2 when passing it to functions that expect a C string.
p needs to be changed to unsigned char * if char is not unsigned.
You have to recalculate the pointers if you unlock the handle. You need to unlock the handle if you want to increase the size.