0

For the following code:

    #include <cs50.h>
    #include <stdio.h>

    int main(void)
    {
        long long card = get_long_long("Number: ");
        printf("%llo\n", card);
    }

Some numbers which I enter print a different number in response.

Example results:

Number: 123 ==> 173 Number: 2 ==> 2 Number: 12 ==> 14 Number: 1234376786782349 ==> 43052427571224215

This also occurs with 'get_long', but not with 'get_int'. Why is the wrong number printing?

1

12 in octal (base 8) is 14, is it significant, no ?, 123 in octal is 173. Well it seems clear what we are doing, maybe you want is:

printf("%lld\n", card);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .