Skip to main content

Posts

Showing posts with the label sample program on strcpy function

Sample C Program To Swap Two Strings Using strcpy() Function.

#include <stdio.h> #include <conio.h> #include <string.h> main() { Char s1[10], S2[10], temp[10]; clrscr(); printf(“ Enter first name \n ”); scanf(“ %s ”, s1); printf(“ Enter second name \n ”); scanf(“ %s ”, s2); printf(“ Before swapping \n ”); printf(“ s1 = %s\ts2 = %s\n ”, s1, s2); strcpy(temp, s1); strcpy(s1, s2); strcpy(s2, temp); printf(“ After swapping \n ”); printf(“ s1 = %s\ts2 = %s\n ”, s1,s2); getch(); } OUTPUT: Enter first name Lavanya Enter second name Suchita Before swapping s1 = Lavanya s2 = Suchita After swapping s1 = Suchita s2 = Lavanya ALSO READ: -- Program to accept a string and print it by using the while loop. -- Program to accept a string in upper case and print it in lower case. -- Program to accept a string in any case and print it by another case. -- Program to accept a string and print each word in new line. -- Program to accept a string and count no of capital letters, no. of small letters and ...