I have the following C code.
Now I know that functions having a return type of int will have implicit return type if there is no return statement. I also get that reading the implicit value is an undefined behaviour. But I can’t seem to understand this consistent behaviour: The output of this code is “hello5”.
If I printed “HelloWorld” then the output will be “HelloWorld10”. It is returning the return type of the printf function?!
I don’t really understand how, can anyone explain?
#include <stdio.h>
int m()
{
printf("Hello");
}
void main() {
int k = m();
printf("%d",k);
}