Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with %lld on Windows

Tags:

c

windows

Why does this code:

#include <stdio.h>

int main(int argc, char** argv) {
    printf("%lld\n", 4294967296LL);
}

emit this for Windows:

0

but this for Linux:

4294967296
like image 710
Jared Oberhaus Avatar asked Mar 19 '09 20:03

Jared Oberhaus


1 Answers

This is because Visual Studio C++ 2003 and earlier do not support %lld. But this code will work:

#include <stdio.h>

int main(int argc, char** argv) {
    printf("%I64d\n", 4294967296LL);
}

Size and Distance Specification (Visual Studio C++ 2003)

Size and Distance Specification (Visual Studio C++ 2005)

like image 54
Jared Oberhaus Avatar answered Sep 28 '22 18:09

Jared Oberhaus