G
G Patel
Hi,
If I want to call functions that don't return int without declaring
them, will there be any harm?
I only want to assign the function(return value) to the type that it
returns, so I don't see how the return value comes to play here.
Ex
int main
{
double val;
val = func();
/* when return value comes here, its a double */
return EXIT_SUCCESS;
}
double func(void)
{
return 5;
/* this will convert 5 to a double value before passing back*/
}
I know why we have prototypes, but declarations I have no clue how they
are useful. The actual function's code will convert the return value
to the proper type, in the call location if we(programmer) know what
type the function is returning, then why do we need declarations? How
do they help?
If I want to call functions that don't return int without declaring
them, will there be any harm?
I only want to assign the function(return value) to the type that it
returns, so I don't see how the return value comes to play here.
Ex
int main
{
double val;
val = func();
/* when return value comes here, its a double */
return EXIT_SUCCESS;
}
double func(void)
{
return 5;
/* this will convert 5 to a double value before passing back*/
}
I know why we have prototypes, but declarations I have no clue how they
are useful. The actual function's code will convert the return value
to the proper type, in the call location if we(programmer) know what
type the function is returning, then why do we need declarations? How
do they help?