【问题标题】:how to convert data type byte[] in c to delphi?如何将c中的数据类型byte []转换为delphi?
【发布时间】:2012-09-19 12:53:41
【问题描述】:

这是我需要转换delphi的代码:

LPBYTE readCharBuff = NULL;
BYTE readBuffSize;

readCharBuff = new BYTE[200];
readBuffSize    = 200;

readCharBuff[readBuffSize] = '\0';

感谢您的帮助

【问题讨论】:

  • Delphi 究竟是从哪里来的?
  • 我猜topicstarter需要把上面的代码转换成Delphi7。但到目前为止,很难说它的目标是什么。
  • 我需要将c中的代码转换为delphi。
  • 代码实际上是 C++ 并且它具有未定义的行为,因为您注销了缓冲区的末尾!

标签: c delphi delphi-7 converter


【解决方案1】:

这里是直译:

var
  readCharBuff: PByte; 
  readBuffSize: Byte; 

.

readCharBuff := nil; 

GetMem(readCharBuff, 200); 
readBuffSize := 200; 

readCharBuff[readBuffSize] := $0; 

【讨论】:

  • 虽然此代码在 XE 中编译,但在 Delphi7 中进行索引访问我宁愿使用 readCharBuff: PByteArray
  • 我喜欢你忠实地翻译了缓冲区溢出! ;-)
猜你喜欢
  • 2016-06-25
  • 2014-09-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-02
  • 2023-01-24
  • 1970-01-01
  • 1970-01-01
  • 2018-03-25
相关资源
最近更新 更多