There are two methods by which you access fields in a structure. You either access the field directly
Code:
typedef struct
{
int field1;
int field2;
}myStruct
int main(void)
{
myStruct a; /* we have access to the structure itself */
a.field1 = 5; /* access directly */
return(0);
}
or you can access the field by reference (indirectly)--
Code:
int main(void)
{
myStruct a;
foo(&a); /* pass the _address_ of the structure */
if(a.field1 == 5)
{
...
};
return(0);
}
void foo(myStruct *b)
{
/* The address of the struct was passed */
/* which means we _don't_ have direct */
/* access to the structure, we just have */
/* a pointer to it. This means we must */
/* "de-reference" or "indirectly access" */
/* the structure's fields. */
b->field1 = 5; /* access field _through_ the pointer */
}
----
enjoy.