Sunday, August 29, 2010

String Operations in cplusplus

,
String Handling:-A string is a collection of  characters.String is  a class in cplusplus and there are three constructors in the String class.
1.)String():-For creating an empty string
2.)String(Const char *str):-For creating a string object from a null terminated string
3.)String(const string &str):-For creating a string object from other string object

#include<iostream.h>
#include<string.h>
void main( )
{
char ch1[] = “Cplusplusexample”;
char ch22[80];
for(int i=0; i
ch2[i]=ch1[i];
ch2[i]=’\0’;
cout<< “The copied string is “<< ch2;
}
Output:-The copied string is Cplusplusexample

0 comments to “String Operations in cplusplus”

Post a Comment