/*Program for Replacing a character*/ #include #include void main() { int replace_char(char *,char,char); char *str; char old_char,new_char; int r; clrscr(); printf("nnnttt Program for Replacing a character"); printf("nnnttt Enter a line of text :"); printf("nnt >> "); gets(str); printf("nnt Enter the Character to find = "); flushall(); scanf("%c",&old_char); printf("nnt Enter the Character to be replaced = "); flushall(); scanf("%c",&new_char); r=replace_char(str,old_char,new_char); printf("nnnttt Line after replacing the characters :"); printf("nnt >> %s",str); printf("nnt Total character replaced = %d",r); getch(); } int replace_char(char *s,char o,char n) { int i,f=0; for(i=0;s[i]!='';i++) { if(s[i]==o) { s[i]=n; f++; } } return(f); }