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; +}