C++20 sections · 1024 units
Open in Course

Case Sensitivity

Letter case in comparisons

Comparison is case-sensitive by default. "Hello" doesn't equal "hello". Uppercase 'H' (ASCII 72) differs from lowercase 'h' (ASCII 104). This affects equality and ordering both. For case-insensitive comparison, convert both strings to the same case first.

Loop through, converting characters with tolower() or toupper(), then compare the results. No built-in case-insensitive comparison exists in standard C++. You implement it yourself.

This keeps the library minimal. Case handling depends on your specific needs and locale.