FIND YOUR NEXT FEW LINES

Results for “extra”

Small, practical examples. Search by task or narrow things down below.

301 snippets foundClear filters
CGetting Started

Run your first program

C: Start with a complete program that prints one line. Follow the run instructions below.

C✓ Tested
CArray transformations

Search a sorted array with bsearch

C: The search uses the same ordering comparator as the sorted input.

C✓ Tested
C++Numbers & algorithms

Search a sorted vector

Use binary_search after ensuring C++ values are sorted.

C++✓ Tested
CBinary formats & structured parsing

Serialize a 16-bit integer in big-endian order

C: Explicit shifts make a byte format independent of the CPU’s native byte order.

C✓ Tested
Docker / ComposeBuild images

Set an image’s default command

Use JSON array syntax for a predictable command.

Dockerfile✓ Tested
CNumbers & memory

Set and test bit flags

Use unsigned masks to combine and test C flags.

C✓ Tested
C++Filesystem operations

Set owner-only read and write permissions

C++: Replace ordinary permission bits with the requested owner permissions.

C++✓ Tested
C++Ownership & optional values

Share ownership with a counted smart pointer

C++: Copies of shared_ptr keep the owned value alive until the last owner is released.

C++✓ Tested
C++Collections

Sort a vector

Sort C++ integer values in ascending order.

C++✓ Tested
CArray transformations

Sort an integer array with qsort

C: The comparator uses relational comparisons to avoid subtraction overflow.

C✓ Tested
C++Collections

Sort and deduplicate values

Sort a C++ vector and erase adjacent duplicates.

C++✓ Tested
C++Ordering & set operations

Sort only the smallest requested prefix

C++: partial_sort orders the selected prefix without guaranteeing the order of the remainder.

C++✓ Tested