All pastes #349530 Raw Edit

Stuff

public text v1 · immutable
·published 2007-02-10 21:43 UTC
rendered paste body
#include <stdio.h>
#include <sys/types.h>

struct foo
   {
    int32_t anumber;
    char firstletter;
    char secondletter;
    char astring[10];
    char thirdletter;
   };

int main(void)
{
 unsigned char *string = "randomstufftoaddanoffset\x00\x01\x00\x00XYfurisgood\x00Zmorestuff";
 struct foo bar = *((struct foo *) (string + 24) );
 printf("First letter is %c.\n", bar.firstletter);
 printf("Integer is %d.\n", bar.anumber);
 printf("Second letter is %c.\n", bar.secondletter);
 printf("String is %s.\n", bar.astring);
 printf("Third letter is %c.\n", bar.thirdletter);

 return 0;
}