#include<stdio.h> #include<conio.h> #include<string.h> void main() { clrscr(); int i=0, j=0, k=0; char str1[20], str2[20], temp[20]; printf("Enter the First String : "); gets(str1); printf("Enter the Second String : "); gets(str2); printf("Strings before swapping are :\n"); printf("String 1 = %s\n",str1); printf("String 2 = %s\n",str2); while(str1[i]!='\0') { temp[j]=str1[i]; i++; j++; } temp[j]='\0'; i=0, j=0; while(str2[i]!='\0') { str1[j]=str2[i]; i++; j++; } str1[j]='\0'; i=0, j=0; while(temp[i]!='\0') { str2[j]=temp[i]; i++; j++; } str2[j]='\0'; printf("Strings after swapping : \n"); printf("String 1 : %s\n",str1); printf("String 2 : %s\n",str2); getch(); }
C program to swap two strings.
Reviewed by
on
December 26, 2019
Rating:
Play free 3D Slots games with the best graphics and sound
ReplyDeleteFree online video slot machines like NetEnt. If you like high quality slots then try out Play the free games here. convert youtube playlist to mp3 With over 200 games, here are the