Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-12

ansistring and fillchar

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Emerson

How can I use fillchar to give an ansistring a value of, say 'xxxxxxxxx'? In other words, I want to create a string that contains only a single character, that is repeated a certain number of times.

Mark

Reply by email

Michael Van Canneyt
to Mark Emerson
Mark Emerson wrote
How can I use fillchar to give an ansistring a value of, say 'xxxxxxxxx'? In other words, I want to create a string that contains only a single character, that is repeated a certain number of times.

Use

S:=StringOfChar('X',30);

Michael.

Reply by email

Thomas Schatzl
to Mark Emerson: How can I use fillchar to give an ansistring a value of, say 'xxxxxxxxx'? In other…

Hello,

How can I use fillchar to give an ansistring a value of, say 'xxxxxxxxx'? In other words, I want to create a string that contains only a single character, that is repeated a certain number of times.

E.g. this should work (with some typecasting ;-):

{$MODE DELPHI}
var
 s : AnsiString;
begin
 SetLength(s, 20);
 fillchar(PChar(s)^, length(s), 'a');
 WritelN(s);
end.

Regards,
Thomas

Reply by email