C++ Strings

Actually C++ strings are two types

1. Traditional C style character string
2. String class type Introduces in Standard C++

Example of C-style string:

Some builtin strings function came from language C

strcpy(s1,s2); //copies s2 into s1

strcat(s1,s2);  //concatenates string s2 at the end of the string s1

strlen(s1); //returns the length of the string s1..length means actually size that means how many letters is in the string with white spaces and spaces

strcmp(s1,s2); //returns 0 if s1==s2 s1 and s2 are same if less than 0 s1<s2 and greater than 0 s1>s2

strchr(s1,ch);returns a pointer at the first occurence f character ch in string s1

strstr(s1,s2); //retruns a pointer to the first occurence of string s2 in string s1

Example here:


In C++ Standard String Class:

Here we are using the library header #include<string> that is c++ built in header for strings manipulation…