Hi,
This might come across as a stupid question, but please do bear with me.
In the following statement:
I thought that the function is of type int, and has no arguments or it is void of any arguments. Since it's an "int" type of function, I thought it would not return anything apart from an integer.
But that does not seem to be the case below:
Code:
#include <stdio.h>
int how (void);
int main (void)
{
printf("This is the main function.\n");
how();
return printf("this is the \"return\" in main function.\n");
}
int how (void)
{
printf("This is a function called \"how\".\n");
return printf("This \"return\" is from the \"how\" function.\n");
}
When I compile this, I get the following:
Code:
me@linux-5mcf:~> gcc how.c -o how
me@linux-5mcf:~> ./how
This is the main function.
This is a function called "how".
This "return" is from the "how" function.
this is the "return" in main function.
I read somewhere that main is always declared as an integer function. So, I thought of writing another function, and declaring it as int, and then including the printf statement in the return. But that too seems to work.
Is it possible, that both the main and the "how" functions are returning the success code of the return printf....statement? Or is there some other reason?