[英]while accepting socket connection
unsigned __int8 Decrypt(unsigned __int8 data[]);
for(;;)
{
if((sConnect=accept(sListen,(SOCKADDR*)&addr,&addrlen)) != INVALID_SOCKET)
{
Print("Socket Connected Successfully!");
char buf[4095];
recv(sListen,buf,sizeof(buf),0);
Decrypt(buf); // Error:IntelliSense: argument of type "char *" is incompatible with parameter of type "unsigned char *"
}
how can i fix this prob :-s 我该如何解决这个问题:-s
Why don't you use this signature: 您为什么不使用此签名:
unsigned char Decrypt(char *data);
instead of 代替
unsigned __int8 Decrypt(unsigned __int8 data[]);
If you do so, you can easily pass buf
to it, since even though buf
is declared as char buf[4095]
, it will become pointer type automatically when you pass it to Decrypt
. 如果这样做,您可以轻松地将
buf
传递给它,因为即使buf
被声明为char buf[4095]
,当您将其传递给Decrypt
时,它将自动变为指针类型。 No need to cast! 无需投放!
调用Decrypt时,将buf强制转换为无符号__int8。
Decrypt((unsigned __int8*)buf);
将其转换为正确的类型............................
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.