#include <stdio.h>

int main() {
     char *ptr = "Ganesha";
        char *sub = "ns";
        //fInd character 'a' in a given string
        int i =0,j=0,k=0;
        while(ptr[i]!='\0'){
                printf("ptr[%d] %d\n",i,ptr[i]);
                                k=i,j=0;
                                while((ptr[k] == sub[j]) && (sub[j]!='\0')){
                                        k++;j++;
                                }
                                if(j==strlen(sub))
                                        printf("sub string found");
                i++;
        }
return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: