C-Style Strings vs std::string

C++ provides two types of strings: C-style (character arrays) and std::string from the Standard Library.

// C-style string
char name[] = "John";

// std::string
#include <string>
string fullName = "John Doe";

cout << fullName;

Prefer std::string for its flexibility and built-in functions.

← PrevNext →