The function accepts two strings, str1 and str2, as parameters of type char * and exchanges their contents. Note that the strcpy function is used to copy the strings and a local character array is used to store string strl temporarily. This function can be called from the main function to exchange strings as shown below.
Note that this function has several limitations. First, the function uses a very inefficient approach to exchange strings. Second, the array representing each string should have enough space to accommodate the other string being copied to it and third, the length of the strings being exchanged is limited by the size of the temp array.
void str_swap(char *str1, char *str2)
char s1 ="Hi";
char s2 ="Bye";
printf("Before Swaping : s1: %s s2:%s \n", s1, s2);
printf("After Swaping s1: %s s2:%s", s1, s2);