str[0] | 'A' |
str[1] | 'B' |
str[2] | 'C' |
str[3] | '\0' |
String Functions | Description |
---|---|
strcpy() | It copies string from one string to another string. |
strcat() | It combines two strings(concatenation) to linked together. |
strlen() | It returns the length of the string. |
strcmp() | It compares the two strings. |
strchr() | It returns the pointer of character. |
strstr() | It returns the pointer of string. |
Displays the length of the string and concatenate string without using string function.
#include <iostream>
#include <string>
using namespace std; //we can also used std::string instead of std.
int main ()
{
string str1 = "Welcome to ";
string str2 = "TutorialRide";
string str3;
int len ;
str3 = str1 + str2; //Concatenates str1 and str2
cout<<"Concatenate String : "<<str3<< endl;
len = str3.size(); //Total length of str3 after concatenation
cout << "String Length is : " << len << endl;
return 0;
}
#include <iostream>
using namespace std;
void display(char s[]);
int main()
{
char str[25]="Welcome to TutorialRide";
display(str);
return 0;
}
void display(char s[])
{
cout<<s;
}