Я должен указать имя, количество акций, цену покупки и текущую цену, а затем рассчитать общую сумму покупки, текущую сумму и прибыль. Затем программа должна вывести имя, общую сумму покупки, текущую сумму и прибыль.Что вызывает это предупреждение об ошибке?
Я получаю сообщение об ошибке или аварии после того, как я ввожу свой вход: (. Нажмите, чтобы увеличить)
Вот то, что я до сих пор:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
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);
}
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)
{
printf("%s\n", name);
printf("buy total %f\n", buytotal);
printf("current total %f\n", currtotal);
printf("profit %f\n", profit);
}
void main()
{
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);
fflush(stdin);
load(name, &share, &buyprice, &currprice);
calc(share, buyprice, currprice, &buytotal, &currtotal, &profit);
output(*name, buytotal, currtotal, profit);
fflush(stdin);
load(name, &share, &buyprice, &currprice);
calc(share, buyprice, currprice, &buytotal, &currtotal, &profit);
output(*name, buytotal, currtotal, profit);
system("pause");
}
Вы продолжаете получать * что * ошибка? Пожалуйста, отредактируйте свой вопрос, чтобы быть как можно точнее. – TRiG
http://postimg.org/image/uayeqr7ot/ – TheEWL
Научитесь использовать отладчик. –