There are three problems with the code.
For starters it is unclear why the pointer vp
is declared as having the type void * though in the program it is used only to point objects of the type double.
Why not to declare it like
double *vp = NULL;
As result this trick with the pointer
(double*)vp = &r;
will not compile because in the left side the expression (double*)vp
is rvalue
and may not be assigned.
You could just write
vp = &r;
The second problem is that this statement
void area(vp);
is also invalid. To call the function you should write
area(vp);
And the third problem is that a function that has the return type void shall not specify an expression in the return statement
This statement shall be removed.
return 1;
From the C Standard (6.8.6.4 The return statement)
1 A return statement with an expression shall not appear in a
function whose return type is void. A return statement without an
expression shall only appear in a function whose return type is void.
There is no sense to declare the parameter of the function as having a referenced type.
The function definition could look like
double area( double dp )
{
const double PI = 3.14;
return dp * dp * PI;
}
The statement with the call pf printf should be moved in main
printf( "circle are is : %.2lf", area( r ) );