Minimal Hello World C++
创建于:2025年1月3日
创建于:2025年1月3日
What's the Absolute shortest and simplest C++ Hello world code you can do?
A common ultra-minimal version (which may compile on many compilers but isn’t strictly standard) is:
cpp#include<iostream> main(){std::cout<<"Hello World";}
This omits an explicit int
return type and drops return 0;
, relying on compiler defaults. If you want to stick to fully standard-compliant C++, the shortest typical form is:
cpp#include <iostream> int main() { std::cout << "Hello World"; }
Either way, these are about as short and simple as it gets for a “Hello World” in C++.