(unsigned char*)"\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf"
如何转换成PUCHAR?

解决方案 »

  1.   

    windef.h中:
    typedef unsigned char UCHAR;
    typedef UCHAR *PUCHAR;所以,根本就不用转换。
      

  2.   

    PUCHAR就是unsigned char*,两者等价。
      

  3.   

    我要用到一个函数原型是这样的
    WriteReserveArea(PUCHAR DataBuffer, UINT Offset, UINT Sectors);但为什么当直接我把"\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf"放入到DataBuffer时会出现这样的错误?
    error C2664: 'WriteReserveArea' : cannot convert parameter 1 from 'char [17]' to 'unsigned char *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
      

  4.   

    这和你的提问好像不是一码事儿吧。你这个直接强制转换就可以了,因为字符数组默认可以转换为char*但没有到unsigned char*的转换。