Перейти к содержимому

Convert Lowercase to Uppercase in C (and Back!) — ASCII Trick Explained

Servox Ctrl

0:00 / 0:00

Convert Lowercase to Uppercase in C (and Back!) — ASCII Trick Explained

17 просмотров · 10 дней назад
Servox Ctrl
24 подписчика
17 просмотров · 10 дней назад
In this video, I explain how to convert lowercase characters to uppercase and vice versa in C — using simple ASCII arithmetic instead of built-in library functions. We break down the logic behind: str[i] = str[i] - 'A' + 'a'; // uppercase to lowercase str[i] = str[i] - 'a' + 'A'; // lowercase to uppercase You'll learn: ✅ Why this works (the ASCII value gap between 'A' and 'a' is always 32) ✅ How to find a letter's position in the alphabet using subtraction ✅ Why you MUST validate character ranges before converting ✅ A bonus XOR trick: str[i] ^= 0x20; ✅ When to prefer toupper() and tolower() from the ctype header instead Perfect for beginners learning C, ASCII fundamentals, and embedded/firmware programmers who often work close to the hardware and need to understand character encoding at a low level. 📌 Topics covered: ASCII table basics Character arithmetic in C String manipulation Case conversion without library functions Common bugs and edge cases 🔔 Subscribe for more C programming and embedded systems content! #C #CProgramming #ASCII #EmbeddedSystems #CodingTutorial #StringManipulation