A char array is a collection of characters, just like a string, but stored in an array format.
cpp
Copy code
char name[10] = "Nikhil";
π Important:
'\0' to mark the end of string."Nikhil" actually takes 7 characters: N i k h i l \0cpp
Copy code
char name[6] = {'N', 'i', 'k', 'h', 'i', 'l'};
π« This wonβt be treated as a string (no \0 at the end)
cpp
Copy code
char name[] = "Nikhil";
β This includes the null character automatically. Memory allocated: 7 bytes.
cpp
Copy code
char name[] = "Nikhil";
cout << name; // Output: Nikhil