I'm having issues using the GetLongLong function. For some reason the output I get doesn't match the input I put in. Here, is my code.

#include <studio.h>
#include <cs50.h>

int main(void)
    // Get credit card number
    long long c_num = GetLongLong();
    printf("%llo/n", c_num);

The program appears to run fine, but when I input "1234567" as the number for GetLongLong, it returns "4553207" from the printf function. Does anyone know why it would do this? Am I using the GetLongLong function incorrectly?

Any help is appreciated.


No, you're using GetLongLong correctly not printing it correctly to stdout. "%llo" prints it in octal (i.e., base 8) instead of decimal (see more here https://www.cs.colostate.edu/~cs157/Fall15/Printf). Use "%lld" instead.

Also, /n simply prints /n. The newline character is '\n'.

ETA: there's a typo in your standard i/o library inclusion ("stdio.h" not "studio.h"), but stackexchange won't let me edit your post to correct just one character.

You must log in to answer this question.

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