T
The Lost Packet
Chris said:karthikbalaguru said:Hi ,
I have the below structure.
struct check_struct{
double a;
char b;
};
My system reports the size of the above structure as 16 bytes.
I understand that there is some padding at the end of the above
structure and hence the size gets calculated to 16 bytes.
But, how to view the data/info that are padded using a debugger
like gdb or visual c++ debugger ?
I used watch windows but, it did not show the padded data .
Any ideas ?
you can try something like the following nasty hack:
___________________________________________________________
#include <stddef.h>
#include <stdio.h>
struct foo {
double m1;
char meof;
};
int main(void) {
char tmp;
struct foo f;
unsigned char* head = (((unsigned char*)&f) +
offsetof(struct foo, meof)) + sizeof(f.meof);
unsigned char* const tail = (unsigned char*)((&f) + 1);
size_t const size = tail - head;
printf("there seems to be %lu bytes of padding at "
"the end of `struct foo'...\n",
(unsigned long int)size);
if (size) {
tmp = head[size - 1];
head[size - 1] = '\0';
printf("pad bytes: %s%c\n\n", head, tmp);
head[size - 1] = tmp;
}
return 0;
}
___________________________________________________________
**** me, I've gorgotten how to read!
--
TLP
- Last night I played a blank tape at full volume. The mime next door
went nuts.
- No, I will not fix your computer.
- Thought: It must be a bitch to write your name in the snow in Arabic...
- Don't sweat the petty things, pet the sweaty things.
- Rice: 1.4 billion Chinese can't all be wrong.
- I'm dreaming of a better world where chickens can cross the road and
not have their motives questioned!
- If you can make a cheesecake you can install a Linux driver from source.
- Don't listen to the do-gooders, condoms are useless. They split,
they leak and they burst. And the human stomach can't handle the impact
of two kilos of cocaine.
- Users who XNA their posts are admitting that their ramblings aren't
worth reading.
- (on Windows) You know why "last known good configuration" almost
never works? Because the last known good configuration was a blank disk.
- Sinister Midget, 15 Jan 2009
*#* Signoff: labo-rat (find / -name \*yourbase\* -exec chown us:us {} \