Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Leerzeichen multiplizieren? (https://www.delphipraxis.net/50808-leerzeichen-multiplizieren.html)

dizzy 1. Aug 2005 22:22

Re: Leerzeichen multiplizieren?
 
Zitat:

Zitat von new32
Delphi-Quellcode:
function leer(count:cardinal):string;
var c:cardinal;
begin
 for c:=1 to count do begin
  result:=result+' ';
 end;
end;
MfG NEW32!

Überhaupt tritt man den Speicher so mit Füßen. Grund ist der selbe wie bei dyn. Arrays auch. (Haben wir hier schon oft genug durchgekaut ;))
Besser:
Delphi-Quellcode:
function leer(count:cardinal):string;
var c:cardinal;
begin
  SetLength(result, count);
  FillChar(result, count, ' ');
end;
\\edit: U.U. muss result[1] oder @result als Parameter für FillChar übergeben werden - habs grad nicht 100%ig im Kopf.

Gruss,
Fabian


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:15 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz