Autor Beitrag
VT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: So 11.01.04 14:08 
Hi,

simple frage ;)

wie kann ich einen pointer wert erhöhen? also der eine pointer variable zeigt ja auf einen speicherbereich, nun will ich aber auf speicherbereich+1 zeigen lassen. in c++ geht das ohne probleme mit einem increment, aber delphi meckert hier rum. Ich denke mal ich kenn die Syntax nich. Wie mach ich das also?

Vielen Dank im Vorraus.

So lonG
Daniel
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: So 11.01.04 14:26 
also bei mir funktioniert das:

ausblenden Delphi-Quelltext
1:
2:
var addr: PLongint; // zeiger auf Longint
inc(Addr)


grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
KidPaddle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 351

WinXP,Linux
D7 Prof, XE7
BeitragVerfasst: So 11.01.04 15:21 
Oder

ausblenden Delphi-Quelltext
1:
Ptr := POINTER(LONGINT(Ptr) + 1);					


Gruß
KidPaddle

Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 11.01.04 15:31 
Zitat:
ausblenden Delphi-Quelltext
1:
2:
var addr: PLongint; // zeiger auf Longint
inc(Addr)


KidPaddle hat folgendes geschrieben:
Ptr := POINTER(LONGINT(Ptr) + 1);


Beide Codes machen was anderes. Der erste erhöht den Zeiger addr um 4 Bytes (= SizeOf(Longint) ). Der zweite Code erhöht den Zeiger um 1 Byte.

_________________
Ist Zeit wirklich Geld?
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 11.01.04 15:51 
Wieso erhöht die Version mit Inc() den Zeiger um 4 Bytes? Inc() hat eine überladene Version mit einem 2ten Parameter bei dem man angeben kann um wieviel erhöht werden soll, aber standardmäßig erhöht Inc() immer nur um eins...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
VT Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: So 11.01.04 15:53 
weil inc um sizeof(longint) erhöht
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 11.01.04 16:03 
Stimmt.. hab mir das grad im CPU-Fenster angeschaut.. der Compiler setzt den Inc() Aufruf so um, dass der Pointer um die Größe der Daten erhöht wird die der Pointer referenziert... das war mir neu.. :shock: :roll:

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 11.01.04 20:34 
Motzi hat folgendes geschrieben:
der Compiler setzt den Inc() Aufruf so um, dass der Pointer um die Größe der Daten erhöht wird die der Pointer referenziert...

Das ist in C übrigens auch so.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert