Contents

Views 8139 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
397 Develop [c] OpenGL 관측점 이동 hooni 2003.04.23 7639
396 Develop [js] 비만 지수 측정(BMI) ㅎㅎ file hooni 2013.04.23 7638
395 Develop [c++] 초간단 스택 두 가지 방식(class, struct) file hooni 2013.04.23 7636
394 Develop [c++] 윈도우 API 정복 예제 file hooni 2013.04.23 7634
393 Develop [c] 소켓 스트림 서버/클라이언트 (UDP) file hooni 2013.04.23 7615
392 Develop [c] 정수를 2진수로 변환 (재귀,비트연산) file hooni 2003.04.23 7607
391 Develop [c] IP 스푸핑(ip spoof) 소스 - 정리해야 함 file hooni 2003.04.23 7577
390 Develop [php] 웹 응용프로그램(engines) 모음 file hooni 2013.04.23 7570
389 Develop [chm] 윈도우즈에서 디버깅 기법(Debugging Applications) file 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++ 팁 모음 문서 file hooni 2013.04.23 7519
Board Pagination Prev 1 ... 33 34 35 36 37 38 39 40 41 42 ... 71 Next
/ 71