Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi String in Array of Char (https://www.delphipraxis.net/53215-string-array-char.html)

mbamler 12. Sep 2005 14:00

Re: String in Array of Char
 
Zitat:

Zitat von PASST
Letztendlich habe ich das jetzt mit StrPCopy(txtChar, txtString) gemacht. Alternativen wären auch folgende gewesen.
Delphi-Quellcode:
  SetLength(txtChar,Length(txtString));
  for i:=1 to length(txtString) do txtChar[i-1]:=txtString[i];
  // oder
  Move(txtString[1],txtChar[0],Length(txtString));
Gewundert hatte mich allerdings warum
Delphi-Quellcode:
    txtChar := 'Dieser Text wird vom Compiler akzeptiert!';  // Warum das jetzt?
das akzeptiert wird. An Compilermagic glaube ich nicht - eher an meine Unwissenheit ;)


Dein txtChar ist letztendlich ein typisierter Pointer, der auf einen Speicherbereich zeigt, der als array of char interpretiert wird.

Deine string-Variable ist aber KEIN array of char... (deshalb fliegt dir die Zuweisung um die Ohren)

wohl aber kann das Literal 'ABC...' als solches interprtiert werden (deshalb klappt das)

Gruß
Matthias


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:08 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