Wednesday, 12 February 2014

write a program to swap two strings.



#include<stdio.h>
#include<string.h>

main()
{
char s1[10]="welcome";
char s2[10]="guest";
char temp[10];
strcpy(temp, s1);
strcpy(s1, s2);
strcpy(s2 ,temp);
}
printf("%s %s",s1,s2);
}
output:s1=guest
          s2=welcome

No comments:

Contact Form

Name

Email *

Message *