c 工具函数

int arrayToStr(unsigned char *buf, unsigned int buflen, char *out,int state)
{
    char strBuf[33] = {0};
    char pbuf[32];
    int i;
    for(i = 0; i < buflen; i++)
    {
        if(state ==1 )
        {
            
        sprintf(pbuf, "%02X", buf[i]);
        }
        else{
            sprintf(pbuf, "%X", buf[i]);
        }
        strncat(strBuf, pbuf, 2);
    }
    strncpy(out, strBuf, buflen * 2);
    printf("out = %s\n", out);
    return buflen * 2;
}
u8 dec_to_hex(int value)
{
    int i;
    char buffer[2];

    u8 hex_temp =0;
    sprintf(buffer, "%x", value);
    hex_temp = (u8)value;

     printf("%x\r\n",hex_temp);

       hex_temp = i;
       return hex_temp;
    // printf("%s\r\n", return_hex);

    // return hex;
}
上一篇:MFC文件流类CFile—从文件取出数据


下一篇:SPAAC的抗体-药物偶联物(ADC)单击化学