Einzelnen Beitrag anzeigen

Sebastian R.

Registriert seit: 12. Feb 2006
94 Beiträge
 
#1

csum-Function von C++ nach Delphi

  Alt 3. Sep 2006, 09:28
Hi Leute,
ich zerbrech mir schon seit geraumer Zeit den Kopf darüber, wie ich folgenden C++-Code in Delphi übersetzen kann.

Code:
 int csum(const void *bufv, int length)
 {
    const unsigned short *buf = (const unsigned short *)bufv;
    unsigned long result = 0;

    while (length > 1) {
        result += *(buf++);
        length -= sizeof(*buf);
    }
    if (length) result += *(unsigned char*)buf;
    result = (result >> 16) + (result & 0xFFFF);
    result += (result >> 16);
    result = (~result)&0xFFFF;

    return (int)result;
 }
Könnt ihr mir helfen?

Danke im Voraus, Mfg, Sebastian R.!
Sebastian R.
Keep on programming!


CyCode.net - Meine Programme, Tutorials und Quelltexte
  Mit Zitat antworten Zitat