Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add formatting to the code block

...

This compliant solution uses memcpy to convert the shorts to an int:

Code Block
bgColor#ccccff
langc
#include <stdio.h>
#include <string.h>

void func(void) {
  short a[2];
  a[0]=0x1111;
  a[1]=0x1111;

  int i = 0x22222222;
  memcpy(a, &i, sizeof a);

  printf("%x %x\n", a[0], a[1]);
}

...