Thread: c prog/conversion

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    13

    Question c prog/conversion

    i am finally getting close to getting this program completed, I hope with just one more error to resolve.
    Thanks in advance
    glenn
    else
    printf("0");
    if (Binary == 128)
    printf(" ");
    }
    temp = Octal;
    printf("\t%o\t%hx\n", Decimal); // <--- for this part when i
    Decimal++; // %o\t%hx\n put i get the
    //octal don't the
    //{ temp = hx // hex value, but when i
    // printf("\t%hx\n") //switch them arround i do get
    //hx++ //the hex value but not where i
    //should
    should i do this ^ (?)

    } while (Decimal < Stop );



    printf("\nContinue? (Y/N): ");
    fgets(Continue,16,stdin);
    }



  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Mmm - it's hard to see, but I think you need to do this

    > printf("\t%o\t%hx\n", Decimal);
    Are you asking why you dont get both printed?
    Well its because you have two % conversions and only one parameter

    This is better
    printf("\t%o\t%hx\n", Decimal, Decimal );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed