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

Given two strings, sort them lexicographical order.


Implementation:

#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;
}

int main(void) {
   char *s,*v;
   
   /* Allocate memory for two strings */
   s=(char*)malloc(sizeof(char));
   v=(char*)malloc(sizeof(char));
   
   /* Get the two input strings from the user to sort them in ascending order or dictionary order */
   scanf("%s",s);
   scanf("%s",v);
   
   /* Compare two strings to see which one is smaller */
   if(strcmp(s,v)>0)
   {
     swap(&s,&v);
   } 
   
   printf("%s\n",s);
   printf("%s",v);
   return 0;
}