例如:字符串为:abcd 显示结果为:61 62 63 64

解决方案 »

  1.   

    0a70: 98 9A 8E 7D 3F 23 43 5A 7B 9D;
    0a80: 34 2E 8E 7D 3F B4 43 C3 3C B1;
    0a90:.....
    0b00:.....
    做成这种效果,很常见的
    大家来帮帮忙
    分不够再加
      

  2.   

    不循环,岂有此理!顺序操作难道总耗时会少么?输出十六进制字符用%x/%X格式化操作符,sprint家族或CString::Format()等都可以用.格式化花不了多少时间的!想更高效直接查表输出,这是个小测试程序:
    #include <iostream>
    #include <assert.h>
    using namespace std ;
    #include <windows.h>
     
    void init_table() ;
    void format( char *pszOutput, const char *pszInput ) ;
    main()  
    {
    char a[1024] ;
    const char * const b  = "tes taidc" ;
    init_table() ;
    format( a, b ) ;
    cout<< a << endl ;
    return  1;  
    }
    static char g_szTable[256][4] ;
    void init_table()
    {
    for( int i = 0 ; i < 256 ; ++ i )
    sprintf( g_szTable[i], "%02X ", i ) ;
    }
    void format( char *pszOutput, const char *pszInput ) 
    {
    assert( pszOutput && pszInput ) ;
    while( *pszInput ) {
    memcpy( pszOutput, g_szTable[*pszInput++], 4 ) ;//32位机处理4字节是最快速的,故连最后的字串结束符一起复制
    pszOutput += 3 ;
    }
    }