University of Lethbridge - CPSC
toLower(string s)
Assignment 1 - Movie1 - SM 25This function takes any string (like a movie title) and returns a version of it where every character is lowercase. This is important because C++ string comparison (using ==, <, or >) is case-sensitive by default. For example:
"Inception"and"inception"would not be equal"The Dark Knight"would not match"the dark knight"
To fix this, we create a lowercase version of each string so that comparisons later in the program are fair and consistent. We do not change the original title stored in memory — we only use the lowercase version for comparing or sorting.
Members only
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 27 more lessons in University of Lethbridge - CPSC.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.