This is a theoretical question. To understand further how a return statement at the end of a function can be manipulated.
Can we do like this:
int intialize1()
{
...do smth;
...do smth;
return initialize2();
}
in other c file
int initialize2()
{
...do other thing;
...do other thing;
return 0;
}
Is this a proper way to do like this?
What you wrote is completely correct, frequently done, and functionally equivalent to:
int initialize1()
{
...do smth;
...do smth;
int x_value; // Create a place to store the return value
x_value = initialize2(); // Get the result of the function, and store it.
return x_value; // Return the stored value.
}
it is perfectly legal to call function from return statement, but you have to make sure that return types of both functions are consistent and there are no data truncation or semantically wrong implicit conversion
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With