DEV Community

Moksh Upadhyay
Moksh Upadhyay

Posted on

πŸš€ Understanding Strings and Characters in C

In C programming, Strings and Characters are fundamental for handling text-based data. But did you know there’s a major difference between 'A' and "A" in C?

βœ… 'A' is a Character β†’ Stored as a single byte in memory.
βœ… "A" is a String β†’ Stored as two bytes (A + \0).

πŸ’‘ Memory Representation:

'A' β†’ Stored as ASCII value 65
"A" β†’ Stored as 65 + 0 (null character)
Quick Tip πŸ’‘
πŸ‘‰ Always use single quotes for characters ('A').
πŸ‘‰ Use double quotes for strings ("Hello").
πŸ‘‰ C strings always end with a null character (\0).

πŸ”₯ Bonus: Want to master Strings in C? Check out my detailed blog where I covered:

βœ… String functions like strlen(), strcpy().
βœ… Pointer to String (the most powerful technique).
βœ… Detailed memory representation for both.
πŸ‘‰ Read my full blog here: Strings and Character in C

Top comments (0)