Count the grand children given parent, children, grandparent

Given a two dimensional array of string like
”luke”, “shaw”
”wayne”, “rooney”
”rooney”, “ronaldo”
”shaw”, “rooney”

Where the first string is “child”, second string is “Father”. 
And given “ronaldo” we have to find his no of grandchildren 
Here “ronaldo” has 2 grandchildren. So our output should be 2.


#include <stdio.h>
#include <stdlib.h> 
#include <string.h>
/* using quick sorting */
int compare(char *s,char *v)
{
 while(*s && (*s==*v))
  s++,v++;
 return (*s-*v);
}

void swap(char *x,char *y)
{
 char temp;
 temp=*x;
 *x=*y;
 *y=temp;
}

int partition(char *s,int start,int end)
{
 int pivot=s[end];
 int pindex=start;
 int i;
 for(i=start;i<end;i++)
 {
  if(s[i]<=pivot)
  {
   swap((s+pindex),(s+i));
   pindex++;
  }
 }
 swap((s+pindex),(s+end));
 return pindex;
}

void quicksort(char *s,int start,int end)
{
 int pivot;
 if(start<end)
 {
  pivot=partition(s,start,end);
  quicksort(s,start,pivot-1);
  quicksort(s,pivot+1,end);
 }
}

int main(void) {
 char *s,*v;
 s=(char*)malloc(sizeof(char)*1000);
 v=(char*)malloc(sizeof(char)*1000);
 scanf("%s",s);
 scanf("%s",v);
 quicksort(s,0,strlen(s)-1);
 quicksort(v,0,strlen(v)-1);
 if(compare(s,v)==0)
  printf("YES");
 else
  printf("NO");
 //printf("%s",s);
 return 0;
}