c prog/conversion

This is a discussion on c prog/conversion within the C Programming forums, part of the General Programming Boards category; i am finally getting close to getting this program completed, I hope with just one more error to resolve. Thanks ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21