I wrote this in notepad and then compiled it with lcc-win
, using the command lc hello.c
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
return 0;
}
The resulting exe was 100 KB. Seems kind of huge for a program that just prints Hello World
. Is this normal? Can I reduce the size? 100 KB isn't really an issue these days but it still seems kind of big for what it does. Wouldn't be too bad if every C code I write comes out as a 100 KB exe though.
1- Everytime you use the include <>
tag you do make a link with a c library and load it in your programm.
That is also why it is important to include only in the files that actualy need the library functions.
2- On the other part, the binary that you generate is always full of important informations (cf : libelf
or ASM
), headers, steps that needs to be here if you want to programm to be run nicely. This does take space to.