I am having a little problem with this program
Code:
#include<stdio.h>
void printstruct(struct patient *, int);
struct patient
{
char id[8];
int systolic;
int diastolic;
int ldlchol;
int hdlchol;
};
int main(void)
{
int i = 0;
struct patient p[10];
FILE *pat;
if ((pat=fopen("patients.dat", "r")) == NULL)
puts("Error reading file");
else
{
while(!feof(pat))
{
fscanf(pat, "%s %d %d %f %f", p[i].id, &p[i].systolic,
&p[i].diastolic, &p[i].ldlchol, &p[i].hdlchol);
i++;
}
}
fclose(pat);
printstruct(p, i);
return 0;
}
void printstruct(struct patient *patientPtr, int i)
{
int x = 0;
FILE *patrpt;
if ((patrpt=fopen("patient.rpt", "w"))==NULL)
puts("Error writing to file");
else
{
fprintf("%20s", "Patient's Report");
fprintf("%s", "Patient ID Blood Pressure Cholesterol Ratio\n");
for (x = 0; x <= i; x++)
{
fprintf("%8s %3d\\%3d %9f", patientPtr->id, patientPtr->systolic,
patientPtr->diastolic,(patientPtr->ldlchol/patientPtr->hdlchol));
}
}
fclose(patrpt);
}
The errors i am getting are:
"patte.c", line 50.13: 1506-280 (W) Function argument assignment between types "
struct {...}*" and "unsigned char*" is not allowed.
"patte.c", line 51.13: 1506-280 (W) Function argument assignment between types "
struct {...}*" and "unsigned char*" is not allowed.
"patte.c", line 54.15: 1506-280 (W) Function argument assignment between types "
struct {...}*" and "unsigned char*" is not allowed.
those are coming from these lines
Code:
else
{
fprintf("%20s", "Patient's Report");
fprintf("%s", "Patient ID Blood Pressure Cholesterol Ratio\n");
for (x = 0; x <= i; x++)
{
fprintf("%8s %3d\\%3d %9f", patientPtr->id, patientPtr->systolic,
patientPtr->diastolic,(patientPtr->ldlchol/patientPtr->hdlchol));
}
}
Thanks