Skip to content
Sunday, November 29, 2026Ideas worth exploring. Knowledge worth sharing.
S. SenseCentralDISCOVER EVERY DAY
C++ Programming

C++ Strings

C++ provides following two types of string representations:

The C-style character string as follows:

char greeting[6]={‘H’,’e’,’l’,’l’,’o’,’\0′};

The standard C++ library provides a string class type that supports all the operations mentioned above, additionally much more functionality. Following is the example:

#include<iostream>

#include<string>

usingnamespacestd;

int main ()

{

string str1 =”Hello”;

string str2 =”World”;

string str3;

// copy str1 into str3

   str3 = str1;

cout<<“str3 : “<< str3 <<endl;

// concatenates str1 and str2

   str3 = str1 + str2;

cout<<“str1 + str2 : “<< str3 <<endl;

return0;

}

Author

  • A senior editor for The Mars that left the company to join the team of SenseCentral as a news editor and content creator. An artist by nature who enjoys video games, guitars, action figures, cooking, painting, drawing and good music.

WRITTEN BY

Taylor Emma

A senior editor for The Mars that left the company to join the team of SenseCentral as a news editor and content creator. An artist by nature who enjoys video games, guitars, action figures, cooking, painting, drawing and good music.

More from this author ↗

Leave a Reply

Your email address will not be published. Required fields are marked *