-
unsigned short만 사용하면 warning이 뜬다.프로그래밍/C++ 2014. 8. 29. 15:38
int main(void) { unsigned short int length = 10; printf("Enter length : "); scanf("%u", &length); printf("value is %u \n", length); return 0; }
위 소스를 컴파일 하면 아래와 같은 warning을 내뿜는다.warning: format ‘%u’ expects argument of type ‘unsigned int *’, but argument 2 has type ‘short unsigned int *’ [-Wformat]
결국 %u와 unsigned short와 타입(포맷)이 맞지 않는 다는 얘기이니 -Wformat 말고 직접 warning을 없애야 한다.
Specifies that a following d , i , o , u , x , X , or n conversion specifier applies to an argument with type pointer to short or unsigned short.
라는 문구가 있으니 잘 새겨들으며, 소스를 수정한다면,
scanf("%hu", &length);
'프로그래밍 > C++' 카테고리의 다른 글
폴더 내 파일 찾아 읽기 (0) 2015.01.23 getline 함수 (0) 2015.01.07 SQLite3 라이브러리 생성하기 (0) 2014.11.13 에러값 체크함수 - isnan (0) 2014.09.22 문자열에서 문자를 추출(strtok, strtok_r) (0) 2014.09.12