The problem here is that the character array *binary gets* overloaded because I am reading in multiple (unknown) number of hex numbers.

I also have the problem of not knowing how many inputs there are so I don't know how to define the array.

Anyway I can circumvent these problems?

Code:

while (scanf("%s\n", hex) == 1) {
for (i=0; i<8; i++) {
if (hex[i] == '0') {
strcat(binary, "0000");
printf("\nIt is a 0");
}
if (hex[i] == '1') {
strcat(binary, "0001");
printf("\nIt is a 1");
}
if (hex[i] == '2') {
strcat(binary, "0020");
printf("\nIt is a 2");
}
if (hex[i] == '3') {
strcat(binary, "0011");
printf("\nIt is a 3");
}
if (hex[i] == '4') {
strcat(binary, "0100");
printf("\nIt is a 4");
}
if (hex[i] == '5') {
strcat(binary, "0101");
printf("\nIt is a 5");
}
if (hex[i] == '6') {
strcat(binary, "0110");
printf("\nIt is a 6");
}
if (hex[i] == '7') {
strcat(binary, "0111");
printf("\nIt is a 7");
}
if (hex[i] == '8') {
strcat(binary, "1000");
printf("\nIt is a 8");
}
if (hex[i] == '9') {
strcat(binary, "1001");
printf("\nIt is a 9");
}
if (hex[i] == 'a') {
strcat(binary, "1010");
printf("\nIt is a 10");
}
if (hex[i] == 'b') {
strcat(binary, "1011");
printf("\nIt is a 11");
}
if (hex[i] == 'c') {
strcat(binary, "1100");
printf("\nIt is a 12");
}
if hex[i] == 'd') {
strcat(binary, "1101");
printf("\nIt is a 13");
}
if (hex[i] == 'e') {
strcat(binary, "1110");
printf("\nIt is a 14");
}
if (hex[i] == 'f') {
strcat(binary, "1111");
printf("\nIt is a 15");
}
} //end for
} //end while