Find last occurrence of character in string: how to use strrchr
#include <stdio.h> #include <string.h> int main () { char str[] = "This is a line"; char *p; p = strrchr(str, 'i'); printf ("Last occurence of 'i' is %d \n", p - str + 1); return 0; }