Mega Code Archive

 
Categories / C / Beginners
 

Program. to find & replace any desired character from the input text

#include <stdio.h> # include <conio.h> 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(" Enter a line of text below:-"); printf(" Line will be terminated by pressing ENTER."); printf(" TEXT:- "); gets(a); printf(" Enter 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(" Here all %c are replaced by %c.",c1,c2); return; }