Problems wprintf with long int c ++

0

Hello, I'm having trouble trying to print "big" integers in c ++.

To be more specific using visual studio 2017

int main() {
    _setmode(_fileno(stdout), _O_U16TEXT);
    long rr = 6448915477954560;
    wprintf(L"%ld\n", rr);
}

Problem: The value shown on the console differs from the one you typed, printing: 608174080

    
asked by anonymous 21.09.2018 / 17:07

1 answer

1

You're probably bursting long with that number . Try:

#include <stdio.h>
#include <fcntl.h>  
#include <io.h>  
#include <wchar.h>



int main() {
    _setmode(_fileno(stdout), _O_U16TEXT);
    long long rr = 6448915477954560;
    wprintf(L"%lld\n", rr);
}

Online compiler with code

    
21.09.2018 / 20:19