Home Delphi - How to get substring from PAnsiChar?

Delphi - How to get substring from PAnsiChar?

user3857505
1#
user3857505 Published in 2018-02-13 12:05:20Z
 How to get a substring from a string or stream pointed by a PAnsiChar? Copy command's document says it does not work well with pointers. http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.Copy
MBo
2#
 Use SetString procedure. If you want to copy a piece from the middle, just use pointer to needed beginning like this: SetString(s, PAnsiChar(@p[3]), 2);  Note that you can use Copy - PChar will be implicitly transformed to string var s: string; p: Pchar; begin p := '12345'; s := Copy(p, 1, 3); Caption := s; 
 You need to login account before you can post.
Processed in 0.325661 second(s) , Gzip On .