Swap two strings

C program to swap two strings.

Program

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define MAX 50

void main()
{
	char str1[MAX], str2[MAX], temp[MAX];

    printf("Enter first string\t:");
    gets(str1);
    printf("Enter second string\t:");
    gets(str2);

    printf("\nBefore swapping");
    printf("\nFirst string\t:%s",str1);
    printf("\nSecond string\t:%s",str2);

    strcpy(temp,str1);
    strcpy(str1,str2);
    strcpy(str2,temp);

    printf("\n\nAfter swapping");
    printf("\nFirst string\t:%s",str1);
    printf("\nSecond string\t:%s",str2);

    getch();
}

Output

Enter first string      :welcome
Enter second string     :coursecrux.com

Before swapping
First string    :welcome
Second string   :coursecrux.com

After swapping
First string    :coursecrux.com
Second string   :welcome