The solution actually depends on the byte ordering of the machine architecture. Assuming that the byte ordering is little endian, and that the size of unsigned short is 2 bytes, the following code does what you want:
#include <stdio.h>
int main()
{
union package
{
struct Nums
{
unsignedshort num1;
unsignedshort num2;
}nums;
char str1[4];
};
union package p;
p.nums.num1 = 30u;
p.nums.num2 = 740u;
char str[4];
str[0] = p.str1[1];
str[1] = p.str1[0];
str[2] = p.str1[3];
str[3] = p.str1[2];
// If the architecture is big endian, p.str1 would contain the required values;
// so you wouldn't need a separate array and the above 4 assignments in that case.
for(int i=0; i<4; i++)
printf("%d ", str[i]);
printf("\n");
return 0;
}
With the assumptions mentioned above, the output of the program would be: