本文整理自网络,侵删。

要点:1.数组名称要用@取地址才能作为地址, 与c++有点不同2.StrCopy函数是把第二个参数复制到第一个参数地址里面去3.StrCat函数是把第二个参数字符串内容,接到第一个参数地址后面
program MyPoint; //指针详解{$APPTYPE CONSOLE}uses SysUtils,windows,Generics.Collections ;
{指针和字符串}procedure MyFunc5();var str : array [1..50] of char; pstr : PChar; //Pchar 也就是 ^Charbegin StrCopy(@str, '田攀学Delphi!'); //数组名称要取地址才能作为首地址 与c++有点不同 StrCat(@str, ' To Be No1 !');//把指针和后面字符串指针内容连接起来 GetMem(pstr, sizeof(char) * 50);//为指针pstr开辟50个char长度的空间 StrCopy(pstr, @str);//赋值字符串 Writeln(pstr); FreeMem(pstr); //释放指针end;
{main主函数}begin MyFunc5(); Readln;//回车退出end.
https://www.cnblogs.com/GodPan/p/3390100.html
相关阅读 >>
Delphi windows 编程[12] - 菜单与菜单资源(1-3)
更多相关阅读请进入《Delphi》频道 >>