C > Beginners Lab Assignments
Program. to find & replace any desired character from the input text.
Program. to find & replace any desired character from the input 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(" 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; }
C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting