2

I´ve been looking over internet and through the man cs50.h to find out why a simple program like this generates values error from 8 onwards, but i couldn't find why reads a value and stores another. It will be nice to find help on this particular issue. Thankyou.

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

int main ()
{
    unsigned long long card_number;
    card_number =  0 ;
    card_number = GetLongLong();
    printf ("%llo \n",card_number);
}
2

No need to initialize card_number to 0 before you initialize it to GetLongLong().

Your variable doesn't really store a different value. Actually, you don't print your value the correct way. To print a long long, you should use %lld not %llo

#include <stdio.h>

int main(void)
{
    unsigned long long x = 4111111111111111;
    printf("%llo\n", x);
    printf("%lld\n", x);
}

Output:

164660424532170707
4111111111111111

The %llo format is used for representing a long long value in octal. See more!

0

GetLongLong() returns a long long, not an unsigned long long as you've declared. Perhaps that's the problem you are experiencing?

You must log in to answer this question.

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