String Concatenation: strcat()

The strcat(first_string, second_string) function concatenates two strings and result is returned to first_string.
#include <stdio.h>    
void main( )  
{  
char ch[20] = {'G', 'o', 'o', 'd', 'm', 'o','r','n','i','n','g','\0'};  
char ch2[10] = {'r','a','j', '\0'};  
strcat(ch,ch2);  
printf("Value of first string is: %s",ch);  
} 
Output:
Value of first string is: Goodmorningraj

Compare String: strcmp()

The strcmp(first_string, second_string) function compares two string and returns 0 if both strings are equal.
Here, we are using gets() function which reads string from the console.

#include <stdio.h>    
void main( )  
{  
char str1[30],  str2[30];  
printf("Enter string1:");  
gets(str1);  //reads string from console  
printf("Enter string2: ");  
gets(str2);  
if(strcmp(str1, str2)==0)  
printf("Strings are equal");  
else  
printf("Strings are not equal");  
 } 
Output:
Enter  string1:  goodmorning
Enter  string2:  goodmorning
Strings are equal

Reverse String: strrev()

The strrev(string) function returns reverse of the given string. Let's see a simple example of strrev() function.

#include <stdio.h>     
void main(){  
char str[30];  
printf("Enter string: ");  
gets(str);   //reads string from console  
printf("String is: %s",str);  
printf("\nReverse String is: %s",strrev(str));  
   }    
Output:
Enter string: catchmecoder
String is: catchmecoder
Reverse String is: redocemhctac

String Lowercase: strlwr()

The strlwr(string) function returns string characters in lowercase. Let's see a simple example of strlwr() function.

#include <stdio.h>   
void main(){  
char str[30];  
printf("Enter string: ");  
gets(str);  //reads string from console  
printf("String is: %s",str);  
printf("\nLower String is: %s",strlwr(str));    
 }    
Output:
Enter string: CATCHMEcoder
String is: CATCHMEcoder
Lower String is: catchmecoder

String Uppercase: strupr()

The strupr(string) function returns string characters in uppercase. Let's see a simple example of strupr() function.

#include <stdio.h>   
void main(){  
char str[30];    
printf("Enter string: ");  
gets(str);   //reads string from console  
printf("String is: %s",str);  
printf("\nUpper String is: %s",strupr(str));  
   }    
Output:
Enter string:  catchmecoder
String is:  catchmecoder
Upper String is: CATCHMECODER

String strstr()

The strstr() function returns pointer to the first occurrence of the matched string in the given string. It is used to return substring from first match till the last character.
syntax:

char *strstr(const char *string, const char *match)

String strstr() parameters

string: It represents the full string from where substring will be searched.
match: It represents the substring to be searched in the full string.

String strstr() example

#include <stdio.h>
#include <string.h>     
void main(){
char str[100]="catchmecoder with c and java";
char *sub;
sub=strstr(str,"catch");
  printf("\nSubstring is: %s",sub);
} 
Output:
Catchmecoder  with c and java