hey guys , i am trying to write this program , the program has 3 arrays
char source[]="abcdefghijklmnopqrstuvwxyz";
char target[]="jfghdfsdyncdbdfklhdslasudfds";
char line[26];
now i have to ask the user to enter a line
cin.getline(line,26)
what i want to do is to check the characters in the user input(line) if it exist in the source array.and then replace each characters with the corresponding one from target array.for example if user enter the word "dad", the program have to check for d,a,d in the source and replace them with the corresponding one from target in this case the output will be djd. any ideas i would really appreciated.
azagorath
0
Newbie Poster
Recommended Answers
Jump to PostSimple, for each character in the line array, search through the source array for the character, then use the same index to replace the characters with that of the target array...You'll most likely want to use two for-loops.
Jump to PostAssuming that you have a source array that isn't abc... then you want to do it with one + one loop. I don't know why you read only 26 characters from the keyboard line. What if I have a long sentence ...
If you have a loop in a loop …
All 5 Replies
nmaillet
97
Posting Whiz in Training
geekru2
0
Newbie Poster
azagorath
0
Newbie Poster
StuXYZ
731
Practically a Master Poster
azagorath
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.