Easy learning with example program codes

CPP String Functions

String Functions are the built-in functions provided by CPP to operate and manipulate a string. CPP provides a number of string functions. Some of the MOST USED string functions are listed below:


strcpy() strcpy(destination, source) Copies a string from source to destination.
strcat() strcat(string1, string2) Concatenates two strings.
strcmp() strcmp(string1, string2) Compares two strings, if same, it returns 0.
strlen() strlen (string name) Returns the length of a string.



#include <iostream.h>  
using namespace std;  
int main( )
char chr1[] = "ROSE";  
char chr2[10];    
int l2 = strlen(chr1);
cout << "Hint: Number of words in my favourite flower name is: " << l2 <<endl;
cout << "Enter the name of my favourite flower: ";
cin >> chr2;
if (strcmp (chr1, chr2) == 0)
cout << "Right Answer!!";
return 0;


Hint: Number of words in my favourite flower name is: 4     
Enter the name of my favourite flower: ROSE                 
Right Answer!!
Posted in CPP   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki