C Source Codes List | Source Code Home
Program : Program to find and replace any desired character from the i/p text.
/* Prg. to find & replace any desired character from the i/p text */
#include
# include
char c1,c2,a[80];
void main()
{
clrscr();
find_rep();
getch();
}
void find_rep(void)
/* Function to find & replace any text */
{
char c1,c2;
char a[80];
int i,j,k;
printf("\nEnter a line of text below:-");
printf("\nLine will be terminated by pressing ENTER.");
printf("\nTEXT:- ");
gets(a);
printf("\nEnter the replaceable & replacing letter respectively:- ");
scanf("%c%c%c",&c1,' ',&c2);
for (j=0;j<80;j++)
{
if (a[j]==c1)
a[j]=c2;
}
puts(a);
printf("\n\t\tHere all %c are replaced by %c.",c1,c2);
return;
}
C Source Codes List | Source Code Home
|
|