What is the smallest C++ program that will compile without any error?
Functionality is not important.
Tokens are the smallest unit in the C program.
hello, The smallest program in C language is Program of hello world.
The smallest program possible would be an empty program. For example, this Javascript program: [empty file]. That actually runs, and produces non-empty machine code, because the Javascript interpreter generates the same boilerplate code for that as it would for a non-empty program.
So actually C program can never run without a main() . We are just disguising the main() with the preprocessor, but actually there exists a hidden main function in the program.
The following should be the shortest:
int main(){}
Note that omitting the return value without invoking undefined behaviour is possible only with main()
.
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