On Wed, Apr 14, 2010 at 12:42:57PM -0400, MSR7 wrote: > > Hi all, > > I declared a struct with four member byte variables, where one member is a > pointer, like this: > > struct Temp > { > unsigned char Var00; > unsigned char Var01; > unsigned char Var02; > unsigned char *Var03; > }; > > When i watch the values in the Watch window, all the variables have eight > bits, except the pointer variable, which is 16 bits. > > All the pointer variables will have 16 bits, whatever you declare it as byte > or word? You didn't declare a byte or a word, you declared a pointer. I always teach that a pointer is a variable that holds addresses. So the 16 bits is the width necessary to hold the address of a char. You must note that pointer to an item and the item itself are two completely different things. So the fact that Var03 is pointing to a char isn't relevant. One last thing, when dealing with structs in C, the typedef operator is definitely your friend and you should spend some time learning how to use it. For example I would have declared the stuct above as: typedef struct Temp { unsigned char Var00; unsigned char Var01; unsigned char Var02; unsigned char *Var03; } Temp_t, *Temp_p; This creates two new types named Temp_t, which is the structure, and Temp_p, which is a pointer to that type of structure. From then on you can use those names getting rid of that horrid struct keyword. For example instead of: struct Temp new1, new2; // The type name has two parts. instead you can declare: Temp_t new1, new2; // Much cleaner. I never do structs in C without typedef. Ever. BAJ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist