The %h is an incorrect format specifier; I think you want %hd.
Code:
#include <stdio.h>
struct record
{
char name[12];
short age;
int salary;
};
int main(void)
{
struct record rd = { "James Freda", 24, 20000 };
printf("My name is %s, I am %hd years old, and "
"my salary is %d. Not much huh?\n\n",
rd.name, rd.age, rd.salary);
return 0;
}
/* my output
My name is James Freda, I am 24 years old, and my salary is 20000. Not much huh?
*/
I chose to use an initialization for rd -- to show you another way to do the same thing -- instead of leaving it uninitialized and assigning to it later. You can only do initialization at the rd's definition, and you would need to do a strcpy() if you later wanted to change rd.name.
This code also shows a different way to split a long string.