AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

C++ pointer to byte array --> Delphi

Ein Thema von WojTec · begonnen am 1. Dez 2013 · letzter Beitrag vom 2. Dez 2013
 
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: C++ pointer to byte array --> Delphi

  Alt 1. Dez 2013, 20:02
This is sorcery!

Seriously, this is C at its finest not really.

As far as I can see, the upcast to unsigned happens because the byte value is leftshifted by eight! That means it's multiplied by 2^8 = 256. As far as I can remember, just unsigned means unsigned int . Only this way, you're able to store the maximum result value of up to 65535.

This way, your first line means "increase a by the sum of k[0] and k[1]*2^8".

Pointer arithmetics work just like in Delphi: If you increase your unsigned char pointer by 12, it's now pointing at the next address 12 bytes "later". In case it had been a pointer to short, it would now have been moved by 24 bytes.

I still don't have the slightest clue what and why is actually happening in this code, but I guess I at least figured out those two lines
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:49 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-2025 by Thomas Breitkreuz