本文介绍了联合成char的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从客户端向服务器发送数据包.

包装:

  • 数据包的结构具有两个联合
  • 联合头和联合数据
  • 联合数据内部具有很多结构
  • I want to send a packet from client to server.

    The packet:

    • the struct of the packet has two union
    • union header and union data
    • union data has a lot of struct inside
    • struct test1
      struct test2


      那么test1有很多数据

      例子


      Then test1 has a lot of data

      Example

      int num1;
      int num2;


      现在我设置


      Now I set

      packet.data.test1.num1 = 1
      packet.data.test1.num2 = 2


      我的sha1check函数:


      My sha1check function:

      char* sha1check(const char* source){
      TCHAR	stemp[1024];
      _tcscpy(stemp,_TEXT(source));
      CSHA1 sha1;
      sha1.Update((UINT_8*)stemp, _tcslen(stemp)*sizeof(TCHAR));
      sha1.Final();
      sha1.ReportHashStl(srtemp, CSHA1::REPORT_HEX_SHORT);
      return (char*)srtemp.c_str();
      }


      使用此函数获取sha1值,包括packet.data.test1.num1packet.data.test1.num2


      Using this function to get the sha1 value including the packet.data.test1.num1 and the packet.data.test1.num2 value

      推荐答案

      写道:​​

      ps:我的英语不好...对不起:(

      ps: my english is poor...sorry :(



      但是您的解释仍然很好.而且您不需要为您的英语道歉;我不希望我能说任何您的母语.



      But your explanation is still good. And you do not need to apologise for your English; I don''t expect I can speak any of your native language.




      这篇关于联合成char的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 15:24