如何将char *转换为unsigned char __gc [] [英] how to convert char * to unsigned char __gc[]

查看:98
本文介绍了如何将char *转换为unsigned char __gc []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用
发送加密的数据 public:int Send(unsigned char __gc [],int,int,SocketFlags)
加密的数据存储在char *变量中.
如何将char *转换为unsigned char __gc []

I want to send encrypted data using
public: int Send(unsigned char __gc[], int, int, SocketFlags)
the encrypted data is stored in the char * variable.
how to convert char * to unsigned char __gc[]

推荐答案

我很久没有做任何CLI C ++了,所以可能更清洁了这样的方式,但是您可以像这样遍历加密的数据;

I haven''t done any CLI C++ in a long time so there''s probably a much cleaner way of doing this but you could just iterate over the encrypted data like this;

char* encrypted = "Hello, World!";
int length = 13;

unsigned char socketData __gc[]  = new unsigned char __gc[length];

for(int i = 0; i < length; ++i)
{
    socketData[i] =  static_cast<unsigned char>(encrypted[i]);
}



希望这会有所帮助,
弗雷德里克·博纳德(Fredrik Bornander)



Hope this helps,
Fredrik Bornander


这篇关于如何将char *转换为unsigned char __gc []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆