๐Ÿ“… Date: Jan 25, 2026
๐Ÿ”ฅ Topic: Introduction to Strings, Char Arrays & ASCII


๐Ÿงต What is a String?

So far, I've dealt with numbers. But apps need text (Names, Messages, Emails). In C++, a String is basically a sequence of characters.

The Array Connection

Technically, a string is just an Array of Characters.
If I write string name = "Sahil";, memory looks like this:

Wait, what is \0?
It's called the Null Terminator. It tells the computer "STOP! The string ends here." Without it, the computer would keep reading garbage memory.


๐Ÿ”ข The ASCII Code (Computer's Secret)

Computers don't understand 'A' or 'B'. They only understand numbers. Every character has a numeric ID called an ASCII Value.

  • 'A' - 'Z': 65 to 90
  • 'a' - 'z': 97 to 122
  • '0' - '9': 48 to 57

๐Ÿ’ป Day 25 Code: Hacking Characters

I wrote a program to reveal the hidden numbers behind characters.

#include <iostream>
using namespace std;

int main() {
    char c = 'A';
    cout << "Character: " << c << endl;
    
    // Typecasting to int reveals ASCII
    cout << "ASCII Value: " << int(c) << endl; 

    // Moving char like numbers
    char next = c + 1; 
    cout << "Next Character (A+1): " << next << endl; // Prints 'B'

    return 0;
}

๐Ÿ’ญ Thoughts

Knowing that 'a' is just 97 is a game changer. I can now convert Uppercase to Lowercase just by adding 32 to the ASCII value!