Contents

조회 수 9723 댓글 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;

}


?

  1. [c] 시스템 보안 과제.. 시간(amc time) 변경

    Date2013.04.23 CategoryDevelop Byhooni Views8469
    Read More
  2. [c] 시간(요일,날짜 포함) 출력하는 프로그램 초간단 코드

    Date2013.04.23 CategoryDevelop Byhooni Views8379
    Read More
  3. [c] 시간 관련 함수 설명과 예제..

    Date2003.04.23 CategoryDevelop Byhooni Views12781
    Read More
  4. [c] 시간 계산 하는 프로그램 소스코드

    Date2003.04.23 CategoryDevelop Byhooni Views7893
    Read More
  5. [c] 스토리지 클래스(변수)

    Date2003.04.23 CategoryDevelop Byhooni Views9246
    Read More
  6. [c] 스택/힙 오버플로우 테스트(overflow)

    Date2003.04.23 CategoryDevelop Byhooni Views8496
    Read More
  7. [c] 숫자(int, Number)를 hex코드로 변환하는 소스

    Date2013.04.23 CategoryDevelop Byhooni Views9723
    Read More
  8. [c] 숫자 맞추는 게임..

    Date2013.04.23 CategoryDevelop Byhooni Views8034
    Read More
  9. [c] 소켓주소 구조체에 대해..

    Date2003.04.23 CategoryDevelop Byhooni Views7910
    Read More
  10. [c] 소켓의 세가지 동작모드

    Date2003.04.23 CategoryDevelop Byhooni Views7934
    Read More
  11. [c] 소켓 프로그래밍 요약..

    Date2003.04.23 CategoryDevelop Byhooni Views8180
    Read More
  12. [c] 소켓 스트림 서버/클라이언트 (UDP)

    Date2013.04.23 CategoryDevelop Byhooni Views8672
    Read More
Board Pagination Prev 1 ... 65 66 67 68 69 70 71 72 73 74 ... 99 Next
/ 99