String is one of the most important datatype in any programing language. Manupulation of String is one of the challangine task in C++. str header contains a str class for c++ string creation and manupulation with advanced features similar to Python.
Download str header with github by command or click here.
gh repo clone priyanshu-lanjewar/cpp-str
- Copy
str
file into your project folder and you are done.
#include "str"
str s01 = "Hello World 01";
str s02("Hello World 02);
std::cin>>s01;
std::cin>>s02;
std::cout<<s01;
std::cout<<s02;
str s = "Hello World";
int len1 = s.len();
int len2 = len(s);
str s1 = "Hello ";
str s2 = "World";
str s3 = " Nice to see You";
str s4 = s1 + s2 + s3 + s4 + " Thankyou";
std::cout<<s4;
Output :
Hello World Nice to see You Thankyou
str a = "Hello ";
str b = "World";
std::cout<<"Before Concatenation"<<std::endl;
std::cout<<a<<std::endl<<b<<std::endl;
a+=b; /// Concatenation of 2 String (With Modification of input [Left]string)
std::cout<<"After Concatenation"<<std::endl;
std::cout<<a<<std::endl<<b<<std::endl;
Output :
Before Concatenation
Hello
World
After Concatenation
Hello World
World