Printing unsigned long long int Value Type Returns Strange Results

前端 未结 4 680
野的像风
野的像风 2021-01-17 13:45

I have a problem while using the printf function to print values of type unsigned long long int

I have no idea what\'s wrong. I\'m using De

4条回答
  •  攒了一身酷
    2021-01-17 13:51

    ULONG_MAX refers to unsigned long and not to unsigned long long. For the latter, use ULLONG_MAX (note the extra L).

    You need to change the printf() calls like so:

    printf("unsigned long long int: \n%llu to %llu \n\n", 0ULL, ULLONG_MAX);
    printf("unsigned long long int: \n%llu to %llu \n\n", ULLONG_MAX, ULLONG_MAX);
    

    This ensures that the arguments to printf() match the format specifiers.

提交回复
热议问题