C Programming
Computer Programming

C program to searches the last occurrence of the specified character using strrchr() function



Write a program in C to searches the last occurrence of the specified character in the given string using strrchr() function

\* C program to searches the last occurrence of the specified character using strrchr() function *\

# include < stdio.h >
# include < string.h >
int   main( )
{

char str[100] ;
char ch ;
char *p ;
printf ("\n Enter a string : ") ;
scanf("%s", str ) ;
printf("\n Enter a Characher for Search : ") ;
scanf("%s", &ch ) ;
p = strrchr(str, ch ) ;
printf("\n String starting from %c at End is : %s", ch, p ) ;
return 0 ;

}

Output of Program :

Output of C program to searches the last occurrence of the specified character using strrchr() function