Write a program to get strings and to substitute character from string1 to string2(equv to UNIX command tr)for example:string1: "abc"string2: "def"the occurrence of 'a' will be replaced by 'd' , 'b' will be replaced by 'e' , 'c' will be replaced by 'f'AND for less complexity assume the string1 and string2 are of same size

Questions by rafiuddin

Showing Answers 1 - 3 of 3 Answers

Arup Ratan Banerjee

  • Jan 29th, 2007
 

#include#include#includemain(){int l1=0,l2=0;clrscr();char string1[20];char string2[20];printf("Please Enter the First String...");gets(string1);printf("nPlease Enter the String to replace the first String");for(int i=0;string1[i]!='];i++){l1++;}for(int j=0;string2[j]!='];j++){l2++;}if(l1!=l2){printf("The two Strings are to be of Same Length");exit(0);}else{for(int k=0;k<=l1-1;k++){string1[k]=string2[k];}}for (int m=0;m<=l1-1;m++){printf("%c",string1[m]);}getch();}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions