C 또는 C++에서 문자 값은 ASCII 값으로 저장됩니다. int를 ASCII로 변환하기 위해 정수와 함께 문자 '0'의 ASCII를 추가할 수 있습니다. int를 ASCII 값으로 변환하는 예를 살펴보겠습니다.
예시
#include<stdio.h>
int intToAscii(int number) {
return '0' + number;
}
main() {
printf("The ASCII of 5 is %d\n", intToAscii(5));
printf("The ASCII of 8 is %d\n", intToAscii(8));
} 출력
The ASCII of 5 is 53 The ASCII of 8 is 56