问题如下:
    USHORT Format3[MAX_PATH]={0};
    char strTmp[]="你好好";
    我如何把strTmp 赋给 Format3
    使Format3变成
    Format3[MAX_PATH]={'你','好','\0'};   
    即:         
    Format3[0]=50403;
    Format3[1]=47811;
    Format3[2]=0;

解决方案 »

  1.   

    Format3[0]=strTmp[0];
    Format3[1]=strTmp[1];
    Format3[2]=strTmp[2];
      

  2.   

    注意汉字
    strTmp[0]、strTmp[1] 表示一个汉字
      

  3.   

    zhaolaoxin错了,char 与 USHORT 类型大小不一,其数组不能一一对应传送。
      

  4.   

    参考代码: USHORT Format3[MAX_PATH]={0};
    char strTmp[]="你好好"; size_t len = ((MAX_PATH-1) * 2  > strlen(strTmp)) ? strlen(strTmp) : (MAX_PATH-1) * 2;
    strncpy( (char *)Format3, strTmp, len ); Format3[len >> 1] &= 0xFF;  //处理奇数个字符,如"你好好a" Format3[(len+1)>>1] = 0;    //字符串结束注意:此示例代码并没有考虑所有情况及兼容性。