#include <stdio.h>
#include <stdlib.h> //atoi
void main(){
char PARK[4] = {'2', '2', '7', '4'};
int Great;
int i;
for(i=0; i<4; i++) {
printf("%c", PARK[i]); //%c로 출력
}
printf("\n");
for(i=0; i<4; i++) {
printf("%d", (PARK[i]&0x0F)); //%d로 출력
}
printf("\n");
Great = (PARK[0]&0x0F)*1000 + (PARK[1]&0x0F)*100 + (PARK[2]&0x0F)*10 + (PARK[3]&0x0F);
printf("%d", Great);
printf("\n");
Great = atoi(PARK);
printf("%d", Great);
printf("\n");
}
출력 결과2274
2274
2274
2274
'메모 > C/C++' 카테고리의 다른 글
| char* -> WCHAR* (wchar_t*) MultiByteToWideChar 함수 (0) | 2012.04.16 |
|---|---|
| converting float to string, string to float (0) | 2012.04.14 |
| Direct2D and Direct3D Interoperability Overview (0) | 2012.04.04 |
| Direct2D dpi, dip (0) | 2012.04.04 |
| LPCWSTR <-> char 변환 (0) | 2012.04.04 |
