I am interested to know how the flash printf() function works when a program exits.
Take the following code:
int main(int ac, char **av) { printf("Hi"); return 0; }
In this case, how does printf() manage to flush its buffer to stdout ?
I think it depends on the platform, so let Linux.
It can be implemented using gcc __attribute__((dtor)) , but then the standard library will be compiler dependent. I guess this is not how it works.
Any explanation or links to documentation are appreciated. Thanks.
source share