Search

Theseus

형변환 하였는데 overflow 가 발생하는 경우

[cast operator 오버플로우 castoperator data type datatype 데이버타입 데이터 타입]
예제
Source Code

#include <stdio.h>

void main()
{
int nVar = 128;
char cResult;

cResult = (char)nVar; // cast operator

printf("%d \n",cResult);
}
Review
char 는 -128~+127 인데 int 형 데이터 128을 char로 변환하면 overflow 가 발생한다.

No comments:

Post a Comment