I am trying to convert a decimal number (max. 255 / 8 bits) to hexadecimal and binary form. For now only tried to run the hexadecimal one, but somehow it keeps crashing without any information after running it. Can anyone spot the mistake?
// The result should in fact be put in a structure variable, and of course numbers > 9 should become letters. I can try that later, but if this doesn't work then any extra things won't either. Also not sure how to declare the variables properly, this is but one variant of the things I tried.
Thanks in advance!
Code:#include <stdio.h> struct hex1 { unsigned result1; unsigned result2; }; int main () { struct hex1; int number; unsigned result1; unsigned result2; printf("enter a number\n"); scanf("%d", & number); result1 = number / 16; result2 = number - (result1 * 16); printf("result %d%d\n",result1,result2); }