All pastes #349526 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-10 21:41 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 = "\x00\x01\x00\x00XYfurisgood\x00Z";
 struct foo bar = *((struct foo *) string);
 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;
}