//string handling functions - C style strings
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char fragment1[] = "I'm a s";
char fragment2[] = "tring!";
char fragment3[20];
char finalString[20] = "";
strcpy (fragment3, fragment1);
strcat (finalString, fragment3);
strcat (finalString, fragment2);
cout << finalString;
return 0;
}
//string handling functions - C style strings
#include <iostream>
#include <cstring>
using namespace std;
int main ()
{
char str1[10] = "Hello";
char str2[10] = "World";
char str3[10];
int len ;
strcpy(str3, str1);
strcat(str1, str2);
len = strlen(str1);
if(strcmp(str1, str2) == 0)
cout<<"matched" <<endl;
return 0;
}
-------------
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str1 = "Hello";
string str2 = "World";
string str3;
int len ;
str3 = str1;
str3 = str1 + str2;
len = str3.size();
if(str1 == str2)
cout<<"matched" <<endl;
return 0;
}