#include void main() { char name[10]; printf("Enter your name: "); gets(name); printf("Your name is: "); puts(name); }
Output
Enter your name: Rahul Bisht
Your name is: Rahul Bisht
#include void main() { char ch[10]={'h','e','l','l','o'}; printf("Length of string is: %d",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); printf("Value of second string is: %s",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); printf("Value of string is: %s",ch); }
Output
Value of string is:
Value of first string is: hello world
#include void main() { char s1[10],s2[10]; printf("Enter string 1: "); scanf("%s",s1); printf("Enter string 2: "); scanf("%s",s2); if(strcmp(s1,s2)==0) printf("Strings are equal"); else printf("Strings are not equal"); }
Output
Enter string 1: hello
Enter string 2: hello
Strings are equal
#include void main() { char s[10]; printf("Enter string: "); printf("%s",s); printf("\n Reverse String is: %s",strrev(s)); }
Output
Enter string:Hello
Reverse String is: olleH
#include void main() { char s[10]; printf("Enter string: "); gets(str); printf("%s",s); printf("\n Lower String is: %s",strlwr(s)); }
Output
Enter string:HELLO
Lower String is: hello
#include void main() { char s[10]; printf("Enter string: "); printf("%s",str); printf("\n Upper String is: %s",strupr(s)); return 0; }
Output
Enter string:hello
Upper String is: HELLO