![]() |
Re: Von C nach Delphi: Benötige Hilfe
Zitat:
Delphi-Quellcode:
type
Float = Single; // oder Double? Vergess ich immer wieder TRectangle = record // hier müsste man eventuell noch das Align anpassen area: float; height: float; width: float; fixed: Integer; ptr: TTreeNode; // oder wie der Typ bei dir nun heißt end; var base_rectangle: TRectangle; |
Re: Von C nach Delphi: Benötige Hilfe
Zitat:
|
Re: Von C nach Delphi: Benötige Hilfe
Zitat:
|
Re: Von C nach Delphi: Benötige Hilfe
Vielen Dank an alle, aber da hätte ich noch einen :cry: :
Delphi-Quellcode:
Lauter Böhmische-Döfer...
treeptr Rootptr()
{ /* initialize the root of the tree */ treeptr t = (treeptr)malloc(sizeof(*t)); t->key = -1; t->op = '?'; t->left = NULL; t->right = NULL; return t; } Lieben Dank Jazzman |
Re: Von C nach Delphi: Benötige Hilfe
|
Re: Von C nach Delphi: Benötige Hilfe
Genauer genommen entspricht "->" "^.", aber Delphi dereferenziert glaub ich bei typisierten Pointern implizit.
|
Re: Von C nach Delphi: Benötige Hilfe
Danke.
D.h. obiges sollte in Delphi dann so etwa aussehen:
Delphi-Quellcode:
FUNCTION Rootptr: PTreeNode; // initialize the root of the tree
VAR t : PTreeNode; BEGIN t := GetMem(PTreeNode, ^t); t.key := -1; t.op := '?'; t.left := NULL; t.right := NULL; Result := t; END; Vielen Dank Jazzman |
Re: Von C nach Delphi: Benötige Hilfe
Statt NULL solltest du besser nil nehmen. Null ist als function deklariert, die einen Null-Variant zurückgibt.
|
Re: Von C nach Delphi: Benötige Hilfe
Danke - NIL sieht tatsächlich besser aus als NULL.
Aber ich tu mich mit dem folgendem noch schwer:
Code:
Da sieht mir mein GetMem irgendwie nicht korrekt aus -- und der Compiler meldet in dieser Zeile ein:
treeptr Rootptr()
{ /* initialize the root of the tree */ treeptr t = (treeptr)malloc(sizeof(*t)); t->key = -1; t->op = '?'; t->left = NULL; t->right = NULL; return t; } Fehler '(' erwartet, aber ',' gefunden Hier nochmal meine 'Übersetzung':
Delphi-Quellcode:
Vielleicht jemand eine Idee?
FUNCTION Rootptr: PTreeNode;
VAR t : PTreeNode; BEGIN t := GetMem(PTreeNode, SizeOf(^t)); t.key := -1; t.op := '?'; t.left := NIL; t.right := NIL; Result := t; END; Gruß Jazzman |
Re: Von C nach Delphi: Benötige Hilfe
GetMem(t, SizeOf(TTreeNode));
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:20 Uhr. |
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 by Thomas Breitkreuz