I want to call a function that calculates the width of a circle.
#include <stdio.h>
void area(double*);
int main()
{
void* vp = NULL;
double r;
printf("input value : ");
scanf(" %lf", &r);
(double*)vp = &r;
void area(vp);
}
void area(double* dp)
{
double result;
result = (*dp) * (*dp) * (3.14);
printf("circle are is : %.2lf", result);
return 1;
}*
I want to call a function in the //void area (vp)//, but I can not catch the error in visual stdio and proceed as it is. Do you know what the cause is?
To call the function, you write area(vp);
not void area(vp);
.
The latter, as it appears in the function main
, is a function prototype and has no run-time effect.
And fix that definition of PI: yours is terribly inadequate given that you use a double
type. See Math constant PI value in C