在delphi中Char,PChar,PByte,Byte,String的相互转换示例
来源:互联网 发布:房租占收入比例 知乎 编辑:程序博客网 时间:2024/04/20 16:12
var s:string; pc:pchar; pb:pbyte; ac:array[1..100] of char; ab:array[1..100] of byte; i:integer;begin s:='this is a test'; pc:=pchar(s);//string->pchar pb:=pbyte(pc);//pchar->pbyte for i:=1 to length(s) do begin ac[i]:=s[i];//string->arrary of char ab[i]:=byte(s[i]);//string->arrary of byte end; s:=pc;//pchar->string s:=string(pb);//pbyte->string s:=c;//arrary of char->string;end;DELPHI里把STRING转来BYTE再转回STRING的方法或代码Byte是8位的,只能代表一个字符。所以应该只有在String只有一位时才能转。String只有一位那就是个Char所以用Ord()和Chr()两个函数就可以互相转。
0 0
- 在delphi中Char,PChar,PByte,Byte,String的相互转换示例
- 在delphi中Char,PChar,PByte,Byte,String的相互转换示例
- 在delphi中Char,PChar,PByte,Byte,String的相互转换示例
- delphi中String,PChar,PByte,Array of Char,Array of Byte 转换
- delphi中String,PChar,PByte,Array of Char,Array of Byte 转换
- delphi中String,PChar,PByte,Array of Char,Array of Byte 转换
- delphi中string,pchar,array of char,pointer,Pbyte,array of byte之间的转化
- String,PChar,PByte,Array of Char,Array of Byte 转换
- String,PChar,PByte,Array of Char,Array of Byte 转换
- delphi pchar char byte string转换问题
- delphi pchar char byte string转换问题
- delphi char数组、string和Pchar的相互转换
- delphi char数组、string和Pchar的相互转换
- delphi中pchar、char、string的定义与区别
- Delphi中pChar char String的关系及转化
- delphi中pchar、char、string的定义与区别
- c#中 uint--byte[]--char[]--string相互转换汇总
- c#中 uint--byte[]--char[]--string相互转换汇总
- Android第三讲——五大布局(UI)
- 《UNIX环境高级编程》笔记--线程的取消选项
- 题目:二叉树的后序遍历
- 滚动CollectionView控制PageControl实现分页浏览的效果
- 黑马程序员—IO流
- 在delphi中Char,PChar,PByte,Byte,String的相互转换示例
- 题目:二叉树的最大深度
- 析构函数抛出异常
- Delphi流操作技巧
- HDU-1875 畅通工程再续(最小生成树[Prim])
- 题目:二叉树的最小深度
- 初步篇7分支结构程序体验项目1求两数正差值
- PHP foreach 的用法
- 多线程