Contents

조회 수 8122 댓글 0
Atachment
첨부 '1'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

숫자를 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;

}


?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
837 Develop [jsp] RSS(xml) 파싱해서 보여주기 ㅎㅎ file hooni 2013.04.23 13217
836 System/OS [linux] 아파치설치/설정 - SSI(Server Side Include) hooni 2003.04.23 13207
835 Develop [ios] App States file hooni 2013.07.22 13195
834 PPT [js] xsl 강의 자료 file hooni 2013.04.23 13186
833 System/OS [linux] 계정관리하기(내공쌓기) hooni 2003.04.23 13163
832 System/OS [linux] 한글 URL 인식할 수 있게 아파치(Apache) 설정 (mod_url.c 설치) hooni 2013.04.23 13067
831 System/OS [linux] Proftpd 설치 가이드 hooni 2003.04.23 13030
830 Develop [html] 캐쉬된 웹페이지 사용하지 않도록 하는 방법 hooni 2003.04.23 13029
829 System/OS [linux] ipfwadm를 이용한 패킷필터링(구버전) hooni 2003.04.23 13025
828 System/OS [linux] DHCP(Dynamic Host Configuration Protocol) 서버 hooni 2003.04.23 13024
827 Develop [js] AngularJS를 소개합니다. file hooni 2014.01.06 13017
826 Develop [php] 심플한 게시판 ㅋㅋ 1 file hooni 2013.04.23 12995
Board Pagination Prev 1 ... 24 25 26 27 28 29 30 31 32 33 ... 98 Next
/ 98