Thread: c prog/conversion

  1. #1
    Registered User
    Join Date
    Sep 2001

    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
    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 i do this ^ (?)

    } while (Decimal < Stop );

    printf("\nContinue? (Y/N): ");

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    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