M
Matthew Jakeman
If i create a cruct like so :
struct test{
char *var1 ;
int var2 ;
short var3 ;
}
and i want to allocate it memory, should i allocate enough to hold the max
amount of data that will go into the char * plus the size of an int plus the
size of a short or do i need to allocate it more memory than this (the
reason i was wondering is i dont know how C handles structs in memory and
how it "binds" the variables together). If this is the case i presume then
allocating ps.var1 is not neccessary as using ps.var1 will use the memory
already allocated. Please point me in the right direction if I am not
getting this.
Cheers
Matt
struct test{
char *var1 ;
int var2 ;
short var3 ;
}
and i want to allocate it memory, should i allocate enough to hold the max
amount of data that will go into the char * plus the size of an int plus the
size of a short or do i need to allocate it more memory than this (the
reason i was wondering is i dont know how C handles structs in memory and
how it "binds" the variables together). If this is the case i presume then
allocating ps.var1 is not neccessary as using ps.var1 will use the memory
already allocated. Please point me in the right direction if I am not
getting this.
Cheers
Matt