History of the Strings
Table of contents
No headings in the article.
Earlier in C language the string data type support was not there. For storing the strings we need to use the "char" datatype array which usually ends with a special character '\0'. Therefore, the size of a character array is always one more than that of the string it is stored. This thing is being supported by C++ also but in addition to that the C++ language also has the inbuilt library string which has some extra functions for string manipulation.
char str[] = "Hashnode";
char str[9] = "Hashnode";
char str[] = {'H','a','s','h','n','o','d','e','\0'};
char str[9] = {'H','a','s','h','n','o','d','e','\0'};
Let's look at some examples for getting a better understanding of the string representation in c++ using C - Style.
// C++ program to demonstrate strings using C style
#include <iostream>
using namespace std;
int main()
{
// Declare and initialize string
char str[] = "Hashnode";
// Print string
cout << str;
return 0;
}