#include <iostream>
using namespace std;
int string_length(char *str)
{
int length=0;
while(*str!='\0')
{
length++;
str++;
}
return length;
}
void string_copy(char *target,char *source)
{
while(*source)
{
*target=*source;
source++;
target++;
}
*target='\0';
}
void string_concat(char *s1,char *s2)
{
while(*s1!='\0')
{
s1++;
}
*s1++=' ';
while(*s2!='\0')
{
*s1=*s2;
s1++;
s2++;
}
*s1='\0';
}
int main()
{
char str[30]="Object Oriented Program";
char source[20]="SRKR CSE";
char target[20];
char s1[20]="OOP";
char s2[20]="C++";
cout<<"length of string is: "<<string_length(str)<<endl;
string_copy(target,source);
cout<<"Copied string is: "<<target<<endl;
string_concat(s1,s2);
cout<<"Concatenated string is : "<<s1<<endl;
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
length of string is:23
Copied string is: SRKR CSE
Concatenated string is:OOP C++
Copied string is: SRKR CSE
Concatenated string is:OOP C++