Hello,

From within a function, I'm trying to give data to certain members of a struct that I created. The struct also has an enum type that I created in it. Say this is the struct and the enum:

typedef enum {cat, dog, rabbit} Animal;

typedef struct {
          Animal petType;
          int       age;
} PetInfo;

Now I want to set the enum type in a function called from my main. How do I pass the struct into the function (as a pointer??) and how do I assign data into the struct from my function when im using a pointer?!?! if I have to... I think it maybe has to do something with the '.' or '->' but I'm not sure. Any help would be appreciated!!

int foo( PetInfo* pInfo)
{
    pInfo->petType = cat;
    // etc. etc

   return 0;
}

int main()
{
    PetInfo MyCat;
    foo( &MyCat );
}

Thank you so much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.