Tja, man sieht man kommt doch nicht auf alles. Danke für den Tipp. Jetzt sieht meine "App" so aus:
BTW: Du castest wie ganz selbstverständlich die Pointer auf int. Ich kenne den C-Standard nicht genau genug, aber ist garantiert, dass int die selbe Größe wie int hat??? Auf AVR, 8051 und x86 ja, aber sonst?Code:#include <stdint.h> #include <stdio.h> #include <stdlib.h> struct ts { uint16_t a; uint16_t b; uint8_t c; uint16_t d; }; int main (void) { struct ts *p; int the_offset; // calculate the offset (cast required as data types are different!) the_offset = ((char *) &p->d) - ((char *) p); printf("offset %d required to access structure element 'd' directly\n", the_offset); }







Zitieren

Lesezeichen