나는 내가해야 할 일에 잘 작동하는 것 같은 다음 프로그램을 작성했다. 그러나, 나는 UINT_MAX가 저를주는 이유 -1 출력하지 4294967295 (의 printf()를 통해), 여기에 지정된 궁금 : https://www.tutorialspoint.com/c_standard_library/limits_h.htmUINT_MAX가 -1을 반환하는 이유는 무엇입니까?
#include <stdio.h>
#include <limits.h>
int main() {
printf("Below is the storage size for various data types.\n\n");
//char data type
printf("**char**\nStorage size: %d byte \t Minimum value: %d \t Maximum value: %d\n\n", sizeof(char), CHAR_MIN, CHAR_MAX);
//signed char data type
printf("**signed char**\nStorage size: %d byte \t Minimum value: %d \t Maximum value: %d\n\n", sizeof(signed char), SCHAR_MIN, SCHAR_MAX);
//unsigned char data type
printf("**unsigned char**\nStorage size: %d byte \t Maximum value: %d\n\n", sizeof(unsigned char), UCHAR_MAX);
//int data type
printf("**int**\nStorage size: %d bytes \t Minimum value: %d \t Maximum value: %d\n\n", sizeof(int), INT_MIN, INT_MAX);
//unsigned int data type
printf("**unsigned int**\nStorage size: %d bytes \t Maximum value: %d\n\n", sizeof(unsigned int), UINT_MAX);
}
나는 세부 사항을 생략하거나 뭔가를 오해 있습니까?
'size_t' ('sizeof' 결과)에'% zu'를 사용하고'unsigned int'에'% u'를 사용하십시오. – BLUEPIXY