Passing pointers to functions

thebath's Avatar, Join Date: May 2008
Newbie Member
Prewarning: The Gwin commands are the graphics window we use

Hey, so i have to, create a function called WeightLoss. This function will take as its ONLY
parameter a POINTER to a Patient. The purpose of thefunction is as follows:
If the Patient passed in is male, the function will reduce the Patient's weight by 10%.
If the Patient passed in is female, the function will reduce the Patient's weight by 20%
#include "stdafx.h"
#include "gwin.h"
#include <fstream>
#include <iostream>

using namespace std;
const int MAXPATIENTS = 10;
const int sex=2;
double	bmi[MAXPATIENTS][sex];

struct patient
	int ID; 
	double Weight;
	double Height;
	bool IsMale;
double weightLoss (double *p);//Problems line 28

int main()
	patient dieters[MAXPATIENTS];
	int i=0;
	ifstream details("Dieters.txt");
	Gwin.writeText(10,0,"ID     BMI:");
	while (i<10)
		if (bmi[i][1]>22&&dieters[i].IsMale)
			Gwin.writeInt(0,15*i, dieters[i].ID);

			Gwin.writeDouble(40,15*i, bmi[i][1]);
		else if(bmi[i][1]>25&&!dieters[i].IsMale)
			Gwin.writeInt(0,15*i, dieters[i].ID);

			Gwin.writeDouble(40,15*i, bmi[i][1]);
	return 0;
	int weightLoss(double *p)//Problems
	int j=j+1;
	bool male;
	if (bmi[j][2]=male)

			bmi [j][1]=bmi[j][1]*0.9;
		else if(bmi[j][2]!=male)
	return bmi;

cpp(43) : error C2664: 'weightLoss' : cannot convert parameter 1 from 'double' to 'double *'
cpp(66) : error C2556: 'int weightLoss(double *)' : overloaded function differs only by return type from 'double weightLoss(double *)'
cpp(28) : see declaration of 'weightLoss'
cpp(66) : error C2371: 'weightLoss' : redefinition; different basic types
(74) : warning C4805: '!=' : unsafe mix of type 'double' and type 'bool' in operation
thebath's Avatar, Join Date: May 2008
Newbie Member
Ok so cant find edit. So far i have the program reading the structs etc, reads the bmi array out puts selected colums from the bmi array. Trouble is with passing the pointer from the function. the newly reduced array of bmi then goes through the nested if functions in the main function