FIND YOUR NEXT FEW LINES

Results for “extra”

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

301 snippets foundClear filters
CNumeric parsing & arithmetic

Compute a two-dimensional vector length

C: hypot avoids unnecessary intermediate overflow compared with squaring both inputs directly.

C✓ Tested
C++Tasks & synchronization

Convert a duration to another unit explicitly

C++: duration_cast converts units and truncates fractional integer units.

C++✓ Tested
C++Text validation & parsing

Convert ASCII text to lowercase safely

C++: Cast each byte to unsigned char before using the cctype function.

C++✓ Tested
CBinary formats & structured parsing

Convert ASCII text to lowercase safely

C: Cast to unsigned char before calling ctype functions on a possibly signed char.

C✓ Tested
CStrings

Convert ASCII text to uppercase

Convert characters with toupper while avoiding signed-char undefined behavior.

C✓ Tested
C++Getting Started

Convert known numeric text to an integer

C++: Convert a trusted literal to an integer before adding. Validate external input before converting it.

C++✓ Tested
CGetting Started

Convert known numeric text to an integer

C: Convert a trusted literal to an integer before adding. Validate external input before converting it.

C✓ Tested
CFile positioning & lifecycle

Copy a file in bounded binary chunks

C: Check read, write, and close errors while copying without loading the entire file.

C✓ Tested
C++Filesystem operations

Copy a file without replacing an existing destination

C++: The default copy_file policy refuses to overwrite an existing destination.

C++✓ Tested
CStrings

Copy text into a fixed buffer

Use snprintf and check for truncation when copying a C string.

C✓ Tested
CStrings & byte buffers

Count a leading run of allowed characters

C: strspn counts bytes at the start that belong to a specified character set.

C✓ Tested
C++Sequence algorithms

Count elements satisfying a predicate

C++: count_if counts matches without constructing a filtered collection.

C++✓ Tested