Hi all,
the following code prints garbage values. I want to read from an array two bytes and print then as a short int after doing ntohs.
What is the bug in the code?
Thanks and Regards,
Prashanth
#include<stdio.h>
struct converter {
unsigned short int i;
};
main() {
struct converter * converts;
char a[9]="12345678\0";
converts = (struct converter*) (a + 0);
printf("12 is printed %u\n", ntohs(converts->i));
}