Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/05/05 08:43
Read: times


 
#84352 - sizeof?
Responding to: ???'s previous message
a=sizeof(int)

typedef struct {
short a,
Byte b,
char[5] c
} alpha

x=sizeof(alpha);

int j;
return sizeof(j);

These are actually more of "compiler macros" than functions, the compiler just determines the size of given variable and compiles the value into the binary.


note x won't be 8 bytes, but, say, 5 (with 16bit addressing) because c is a pointer, not the actual array. Thus, this is quite problematic with determining an array size.
(of course if the array contains a null-terminated string it's best to use strlen() from <string.h>)


List of 4 messages in thread
TopicAuthorDate
identifying the length of a variable            01/01/70 00:00      
   solution            01/01/70 00:00      
      Solution?            01/01/70 00:00      
         sizeof?            01/01/70 00:00      

Back to Subject List