Reputation: 47
This shows an error, the stack around 'child' was corrupted. I have thought of every possible error, like data type matches, passing the address and the address is received properly, assigning the value properly through scanf, etc, etc, but the error remains. Help appreciated.
#include <stdio.h>
float totalPeople(float* child, float* adult, float* senior);
void main()
{
float child, adult, senior;
float totalP = totalPeople(&child, &adult, &senior);
return 0;
}
float totalPeople(float* child, float* adult, float* senior)
{
printf("Enter total number of child: ");
scanf("%lf", child);
printf("Enter total number of adult: ");
scanf("%lf", adult);
printf("Enter total number of senior: ");
scanf("%lf", senior);
float totalP = *child + *adult + *senior;
return totalP;
}
Upvotes: 0
Views: 35
Reputation: 354
You need to use the format specifier %f
with type float
.
%lf
is for double.
Upvotes: 1