Results for “literal”
Small, practical examples. Search by task or narrow things down below.
Check a literal filename suffix
C: Check lengths before subtracting so a short input cannot produce an invalid pointer.
C✓ Tested
Check a literal prefix in C++17
C++: Use string compare because starts_with was introduced after C++17.
C++✓ Tested
Check a literal prefix with ordinal comparison
C#: Choose StringComparison.Ordinal when a prefix is a protocol token rather than culture-dependent text.
C#✓ Tested
Check a literal string prefix
C: strncmp compares at most the prefix length; both inputs must be valid strings.
C✓ Tested
Check a literal suffix in C++17
C++: Check lengths before subtracting to avoid an unsigned underflow.
C++✓ Tested
Compare a value literally inside a conditional
Bash Scripts: Quoting the right side of an equality test makes wildcard characters literal.
Bash Scripts✓ Tested
Filter lines by literal text
Linux Commands: Filter lines by literal text using GNU/Linux commands in an empty practice directory.
Linux Commands✓ Tested
Keep a dollar sign literal
PowerShell: Keep a dollar sign literal using PowerShell 7.
PowerShell✓ Tested
Keep exec-form arguments literal
Docker / Compose: JSON exec form does not expand shell environment variables.
Docker / Compose✓ Tested
Parse a Boolean literal
Parse a Boolean literal in a complete Rust program using the standard library.
Rust✓ Tested
Print text containing percent characters literally
Bash Scripts: Never use untrusted text as the printf format string.
Bash Scripts✓ Tested
Quote a literal search term for a regex
C#: Regex.Escape prevents metacharacters in a literal term from changing the pattern.
C#✓ Tested