Sort two strings without using library function (using swapping of words)

Given two strings, sort them in lexicographical order without using library functions



#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/* Function to swap two strings */
void swap(char **x,char **y)
{
   char *temp;
   temp=*x;
   *x=*y;
   *y=temp;
} 

/* Function to compare two strings or words */
int compare(char *s,char *v)
{
   while(*s && *s==*v)
    s++,v++;
   return (*s-*v);
}


int main(void) {
   char *s,*v;
   
   /* Allocate memory for the strings */
   s=(char*)malloc(sizeof(char));
   v=(char*)malloc(sizeof(char));
   
   /* Get the two strings from the user */
   scanf("%s",s);
   scanf("%s",v);
   
   /* Compare the two strings to sort them in ascending order */
   if(compare(s,v)>0)
   {
     swap(&s,&v);
   } 
   
   /* Print the sorted strings */
   printf("%s\n",s);
   printf("%s",v);
   
   return 0;
}