/*
strlen(str) returns length of the string str.
strcpy(str1,str2) copy the string from the str2 to str1.
strcat(str1,str2) catenate str1 to str2.
*/
#include <iostream>
#include<conio>
#include<cstring>
void main ()
{
char str1[10] = "Hello";
char str2[10] = "World";
char str3[10];
int len ;
// copy str1 into str3
strcpy( str3, str1);
cout << "strcpy( str3, str1) : " << str3 << endl;
// concatenates str1 and str2
cout << "strcat( str1, str2): " << strcat( str1, str2)<< endl;
// total lenghth of str1 after concatenation
len = strlen(str1);
cout << "strlen(str1) : " << len << endl;
getch();
}
strlen(str) returns length of the string str.
strcpy(str1,str2) copy the string from the str2 to str1.
strcat(str1,str2) catenate str1 to str2.
*/
#include <iostream>
#include<conio>
#include<cstring>
void main ()
{
char str1[10] = "Hello";
char str2[10] = "World";
char str3[10];
int len ;
// copy str1 into str3
strcpy( str3, str1);
cout << "strcpy( str3, str1) : " << str3 << endl;
// concatenates str1 and str2
cout << "strcat( str1, str2): " << strcat( str1, str2)<< endl;
// total lenghth of str1 after concatenation
len = strlen(str1);
cout << "strlen(str1) : " << len << endl;
getch();
}
Output
No comments:
Post a Comment