You have a few errors, can you try this:
void load(char *name, float *share, float *buyprice, float *currprice)
{
printf("Enter stock name");
gets(name);
printf("Enter share, buyprice, currprice");
scanf("%f %f %f", share, buyprice, currprice); // changes: removed &*
}
void calc(float share, float buyprice, float currprice, float *buytotal, float *currtotal, float *profit)
{
*buytotal = share * buyprice;
*currtotal = share * currprice;
*profit = *currtotal - *buytotal;
}
void output(char *name, float profit, float buytotal, float currtotal) // changes: char name to char *name
{
printf("%s\n", name);
printf("buy total %f\n", buytotal);
printf("current total %f\n", currtotal);
printf("profit %f\n", profit);
}
int main(void) //changed to int main(void)
{
char name [25];
float share, buyprice, currprice, buytotal, currtotal, profit;
load(name, &share, &buyprice, &currprice);
calc(share, buyprice, currprice, &buytotal, &currtotal, &profit);
output(name, buytotal, currtotal, profit); //changed *name to name
fflush(stdin);
load(name, &share, &buyprice, &currprice);
calc(share, buyprice, currprice, &buytotal, &currtotal, &profit);
output(name, buytotal, currtotal, profit); //changed *name to name
fflush(stdin);
load(name, &share, &buyprice, &currprice);
calc(share, buyprice, currprice, &buytotal, &currtotal, &profit);
output(name, buytotal, currtotal, profit); //changed *name to name
return 0; //Added this line
}
1
solved How can I access an array in C