|
|||||||||||
|
Re: Are bad developer libraries the problem with M$ software?
From: Ali Saifullah Khan <whipaz(at)gem.net.pk>
Date: Fri Nov 22 2002 - 12:27:53 EST Here is a test done on the return of sizes by sizeof() using pointers. #include <iostream.h>
int main(void) {
int len = sizeof(testbuff);
c:>debug\testbuff
The output from this is 4096 but infact it should be returning 1024. Apparently, using a pointer has multiplied the value of the original size of the testbuff[] buffer by the size of the " pointer " ? char pointers have a size of 4 bytes.....as is shown when output is 4 bytes using " int len = sizeof((char*)testbuff); "
c:>debug\testbuff
so sizeof is returning the size of the "first" entity passed to it, that being the size of the pointer. " * "
Whats confusing is when sizeof outputs the value for something like " char *
testbuff[] "
Rather strange behaviour. ???
> ----- Original Message -----
This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 14:02:44 EDT |
||||||||||
|
|||||||||||