Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Swapping two strings using call by value in C

//Call by Value Example - Swapping 2 Strings using Call by Value
#include <stdio.h>
 
 
void swap(char *, char *);
 
int main()
{
   char  *x, *y;
 
   printf("Enter the value of x and y\n");
   scanf("%s%s",&x,&y);
 
   printf("Before Swapping\nx = %d\ny = %d\n", x, y);
 
   swap(x, y); 
 
   printf("After Swapping\nx = %d\ny = %d\n", x, y);
 
   return 0;
}
 
void swap(char *a, char  *b)
{
   char  *temp;
 
   temp = b;
   b = a;
   a = temp;
    printf("Strings of a and b is %s  %s\n",a,b);
}