Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smallest C++ Program that will compile [closed]

Tags:

c++

What is the smallest C++ program that will compile without any error?

Functionality is not important.

like image 875
user1576209 Avatar asked Aug 04 '12 14:08

user1576209


People also ask

What is the smallest program to compile and run in C?

Tokens are the smallest unit in the C program.

What could be smallest program in C?

hello, The smallest program in C language is Program of hello world.

What is the smallest program possible?

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.

Can you run C without main?

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.


1 Answers

The following should be the shortest:

int main(){}

Note that omitting the return value without invoking undefined behaviour is possible only with main().

like image 72
Psychonaut Avatar answered Oct 26 '22 07:10

Psychonaut