Есть некоторая проблема с частью «вычислить итог», но я не уверен, что это такое. Все остальное работает нормально, кроме этого. Я каждый раз получаю ошибку result_pointer != nullptr.
void CalculateTotal(double pricePerGallon, double* totalPtr)
//input price per gallon
//declare, ask and get the number of gallons
//calculate the total
//input/output parameter for the total
{
//declare, ask and get the number of gallons
int numGal = 0;
double tot;
printf("Enter the number of gallons requested: ");
scanf("%d", numGal);
//calculate the total
tot = numGal * pricePerGallon;
*totalPtr = tot;
printf("Your total is %f.", totalPtr);
}
не уверен, имеет ли это значение, но я назвал это в другом определении функции следующим образом:
CalculateTotal(itemNumber, &total);
(Я просто изучаю программирование для своего класса, поэтому чем проще объяснение, тем лучше. Это не C++, кстати, просто C.)
scanf("%d", numGal);
Вам нужно передать адрес здесь.scanf("%d", &numGal);
- person Johnny Mopp   schedule 22.04.2021