Contents

조회 수 8123 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
729 Develop [js] 양원님이 공유해 주신 유료(5$란다ㅋ) 자료 ㅋㅋ secret hooni 2013.04.23 7948
728 Develop [js] 실행되는 디렉토리 확인하는 스크립트.. hooni 2013.04.23 6766
727 Develop [js] 스타크래프트(starcraft).. file hooni 2013.04.23 6641
726 Develop [js] 스크롤을 포함한 마우스 위치 찾는 코드 hooni 2003.04.23 8505
725 Develop [js] 스크롤 이벤트 막기 hooni 2015.04.14 1013
724 Develop [js] 숫자만 입력하게 하는 자바스크립트 hooni 2013.04.23 6798
723 Develop [js] 순환참조에 의한 메모리 누수 관련 file hooni 2013.12.17 10846
722 Develop [js] 수학 공식을 제공하는 Math 객체 hooni 2013.04.23 15415
721 Develop [js] 수명체크 프로그램 ㅋㅋ file hooni 2013.04.23 6840
720 Develop [js] 셀렉트박스(select)의 옵션(option) 동적으로 추가/제거 file hooni 2013.04.23 8061
719 Develop [js] 서서히 나타나는 화면.. ㅋㅋ hooni 2013.04.23 6196
718 Develop [js] 새로고침(refresh)방법과 다른 페이지 바꾸기.. hooni 2003.04.23 6521
Board Pagination Prev 1 ... 33 34 35 36 37 38 39 40 41 42 ... 98 Next
/ 98