I am trying to solve a problem wherein if a pattern appears in a string i can figure it out and tell the position where it is occuring. The thing is that what is happening is that for example i have a original string as "Rohan" then i am trying to traverse this string. And so i increment the pointer that is pointing to it. And this should enable me to traverse the string while the end of the string is not reached. But in the current set up i get stuck at o and it does not seem to move ahead.

[insert]
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int search (char *s, char *p);

int main(void){
	
	//char *s, *p;
	char s1[] = "NagpurKicit";
	char s2[] = "Kicit";
	int pos;

	pos = search(s1, s2);
	return 0;
}

int search(char *s, char *p){
	
	int i,slen, plen, posn = 0, lenc = 0;
	char ss, pp;
	int found;
	char *sc, *pc;
	sc = s;
	pc = p;
	slen = strlen(s);
	plen = strlen(p);
	ss = *s; 
	pp = *p;

	printf("\n %c", ss);
	printf("\n %c", pp);

	printf("\n %d", slen);
	printf("\n %d", plen);

	for(i = slen ; s > 0; s--)
	{

		posn++;

		if(ss == pp)
		{	
			s++;
			p++;
			ss = *s;
			pp = *p;
			++lenc;
			if(pp == '\0')
			{
				if(lenc == plen)
					found = 1;
				break;
			}

			if(found == 1)
				break;
		}
		s++;
		ss = *s;
	}

	posn = posn - lenc;
	return posn;
}
The code is not working right now it has lots of glitches which i am trying to sort out. So please ignore that.