Contents

Views 8122 Comment 0
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

숫자를 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
No. Category Subject Author Date Views
345 System/OS [linux] Proftpd 설치 가이드 hooni 2003.04.23 13021
344 System/OS [linux] DHCP(Dynamic Host Configuration Protocol) 서버 hooni 2003.04.23 13023
343 Develop [html] 캐쉬된 웹페이지 사용하지 않도록 하는 방법 hooni 2003.04.23 13028
342 System/OS [linux] 한글 URL 인식할 수 있게 아파치(Apache) 설정 (mod_url.c 설치) hooni 2013.04.23 13058
341 System/OS [linux] 계정관리하기(내공쌓기) hooni 2003.04.23 13157
340 PPT [js] xsl 강의 자료 file hooni 2013.04.23 13184
339 Develop [ios] App States file hooni 2013.07.22 13193
338 System/OS [linux] 아파치설치/설정 - SSI(Server Side Include) hooni 2003.04.23 13206
337 Develop [jsp] RSS(xml) 파싱해서 보여주기 ㅎㅎ file hooni 2013.04.23 13206
336 Develop [c#] 파일(File) 쓰기 ㅎㅎ hooni 2013.04.23 13289
335 Develop [ios] 간단한 방법으로 OS버전 확인하기. hooni 2013.09.24 13306
334 System/OS [linux] Xwindow/Xmanager 사용 hooni 2003.04.23 13332
Board Pagination Prev 1 ... 65 66 67 68 69 70 71 72 73 74 ... 98 Next
/ 98