Hi guys! I have a program that makes you choose what kind of number conversion you would like to do between Binary to Octal and Binary to Hexadecimal . Here's the function that converts binary to hexadecimal:

int bintohex(void){
fract=0; bits=0;
 printf("Enter any binary number: ");

    while ((ch=getchar()) != EOF && ch != '.' && ch != '\n') {
    switch(ch) {
            case '0':
                whole = whole * 2;
            case '1':
                whole = whole * 2 + 1;
                printf("Bad input\n");
                return 1;
    printf("Hexadecimal value: %lX", whole);

Before all that, I made these conversions seperately (as in individual programs) and they worked perfectly fine. But now that I put them in one program (the one with the switch statement), it wouldn't even let the user to input a binary and just prints the answer as "0". And when I tried to put scanf("%d", &ch);,it would still answer "0".

Can someone tell me what I did wrong? Or the things that needed to be changed? Thank you very much in advance!

I would firstly take in a validated binary string ... then convert that.