#include void main() { char ch[10]={'h','e','l','l','o'}; cout<<"Length of string is:"<< strlen(ch); }
Output
Length of string is:
5
#include void main() { char ch[10]={'h','e','l','l','o'}; char ch2[10]; strcpy(ch2,ch); cout<<"Value of second string is:" << ch2; }
Output
Value of second string is:
hello
#include void main() { char ch[10]={'h', 'e', 'l', 'l', 'o'}; char ch2[10]={'w','o','l','d'}; strcat(ch,ch2); cout<<"Value of string is:" << ch; }
Output
Value of string is:
Value of first string is: hello world
#include void main() { char s1[10],s2[10]; cout<<"Enter string 1:"; cinr>>s1; cout<<"Enter string 2:"; cin>>s2; if(strcmp(s1,s2)==0) cout<<"Strings are equal"; else cout<<"Strings are not equal"; }
Output
Enter string 1: hello
Enter string 2: hello
Strings are equal
#include void main() { char s[10]; cout<<"Enter string: "; cin>>s; cout<<"Reverse String is:" << strrev(s); }
Output
Enter string:Hello
Reverse String is: olleH
#include void main() { char s[10]; cout<<"Enter string: "; gets(str); cout<< s; cout<<"Lower String is:" << strlwr(s); }
Output
Enter string:HELLO
Lower String is: hello
#include void main() { char s[10]; cout<<"Enter string:" << str; cout<<"Upper String is:" << strupr(s); return 0; }
Output
Enter string:hello
Upper String is: HELLO