Develop
2013.04.23 15:09
[c] 숫자(int, Number)를 hex코드로 변환하는 소스
Views 8139 Comment 0
Attachment '1' |
---|
숫자를 hex 코드로 변환
/* print input in hex */ void print_hex( int input ){ int var, i; int len = 0; char buf[255]; do{ var = input % 16; input /= 16; /* try to convert ascii code */ if( var<10 ) buf[len] = var+48; else buf[len] = var+55; len++; }while( input>0 ); /* bigger than 16? then try again */ /* print reversely */ for ( i=len; i>0; i-- ) putchar( buf[i-1] ); putchar( '\n' ); } int main( int argc, char** argv ){ int input; printf( "input number: " ); scanf( " %d", &input ); /* print hex with printf */ printf( "%x\n", input ); /* print hex with my function */ print_hex( input ); return 0; }
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
397 | Develop | [c] OpenGL 관측점 이동 | hooni | 2003.04.23 | 7639 |
396 | Develop | [js] 비만 지수 측정(BMI) ㅎㅎ | hooni | 2013.04.23 | 7638 |
395 | Develop | [c++] 초간단 스택 두 가지 방식(class, struct) | hooni | 2013.04.23 | 7636 |
394 | Develop | [c++] 윈도우 API 정복 예제 | hooni | 2013.04.23 | 7634 |
393 | Develop | [c] 소켓 스트림 서버/클라이언트 (UDP) | hooni | 2013.04.23 | 7615 |
392 | Develop | [c] 정수를 2진수로 변환 (재귀,비트연산) | hooni | 2003.04.23 | 7607 |
391 | Develop | [c] IP 스푸핑(ip spoof) 소스 - 정리해야 함 | hooni | 2003.04.23 | 7577 |
390 | Develop | [php] 웹 응용프로그램(engines) 모음 | hooni | 2013.04.23 | 7570 |
389 | Develop | [chm] 윈도우즈에서 디버깅 기법(Debugging Applications) | hooni | 2013.04.23 | 7553 |
388 | Develop | [c] 시어핀스키 가스킷..(p.582, A.2 - 두번째) | hooni | 2003.04.23 | 7533 |
387 | Develop | [php] 데이터를 엑셀,워드 형태로 변환할 때 헤더(ms-office) | hooni | 2013.04.23 | 7521 |
386 | Develop | [chm] 비주얼 C++ 팁 모음 문서 | hooni | 2013.04.23 | 7519 |