From 8128a05f2e9016079a85388278358890e47484a2 Mon Sep 17 00:00:00 2001 From: OpenBot Engineer Date: Thu, 12 Nov 2026 23:58:51 -0600 Subject: [PATCH] Add a classic C++ Hello World example. A self-contained program under examples/hello_world that compiles with g++/clang++ and prints a greeting to stdout. Includes a small Makefile. --- examples/hello_world/.gitignore | 2 ++ examples/hello_world/Makefile | 17 +++++++++++++++++ examples/hello_world/README.md | 19 +++++++++++++++++++ examples/hello_world/main.cpp | 6 ++++++ 4 files changed, 44 insertions(+) create mode 100644 examples/hello_world/.gitignore create mode 100644 examples/hello_world/Makefile create mode 100644 examples/hello_world/README.md create mode 100644 examples/hello_world/main.cpp diff --git a/examples/hello_world/.gitignore b/examples/hello_world/.gitignore new file mode 100644 index 0000000..04fbb97 --- /dev/null +++ b/examples/hello_world/.gitignore @@ -0,0 +1,2 @@ +hello_world +hello_world.exe diff --git a/examples/hello_world/Makefile b/examples/hello_world/Makefile new file mode 100644 index 0000000..ea461b6 --- /dev/null +++ b/examples/hello_world/Makefile @@ -0,0 +1,17 @@ +CXX ?= g++ +CXXFLAGS ?= -std=c++17 -Wall -Wextra -Werror -O2 + +.PHONY: all run test clean + +all: hello_world + +hello_world: main.cpp + $(CXX) $(CXXFLAGS) -o $@ main.cpp + +run: hello_world + ./hello_world + +test: run + +clean: + rm -f hello_world diff --git a/examples/hello_world/README.md b/examples/hello_world/README.md new file mode 100644 index 0000000..ec938b7 --- /dev/null +++ b/examples/hello_world/README.md @@ -0,0 +1,19 @@ +# Hello World (C++) + +A classic Hello World program that prints a greeting to stdout. + +## Build and run + +Requires a C++17 compiler (`g++` or `clang++`). + +```bash +cd examples/hello_world +make run +``` + +Or without make: + +```bash +g++ -std=c++17 -Wall -Wextra -Werror -O2 -o hello_world main.cpp +./hello_world +``` diff --git a/examples/hello_world/main.cpp b/examples/hello_world/main.cpp new file mode 100644 index 0000000..bc8f460 --- /dev/null +++ b/examples/hello_world/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello, World!" << std::endl; + return 0; +}