I want to create a function that tests Trialist.IsMale and if the trialist is male, reduce their weight by 10%, and if female, adjust their weight by 20%. The function can only have 1 parameter which is a pointer to a patient in the struct.
I apologise if this isn't very clear, but hopefully someone out there will know what I'm getting at!
you access members of a structure by the syntax StructName.ElemName.
so i am guessing you want to establish the variable in the main function (maybe through user input?) and then you want to call the function you are talking about. it would be something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void changeWeight(patient*); //prototype of the function
int main(void)
{
Trialist[0].Weight = 10; //set value for weight
Trialist[0].IsMale = true; //lets suppose the person is male
changeWeight(&Trialist[0]); //you wanted pointer, so send the address
return 0;
}
void changeWeight(patient *Person) //stores the address in a pointer
{
if((*Person).IsMale == true) //be sure to dereference with (*Person)
{
(*Person).Weight *= 0.9;
}
}