hi, i am new in programming , can any one tell me how to repalce the string with the other, i have made a program which takes different alphabets as input and display them as different words....but i am unable to print at the end only those alphabets which i have inserted and then only those words for which i have entered the alphabet (in a collective /combined manner)
can anyone help me out..?
output:(which i want)
enter msg :a
your msg is hello
u want to exit: n
enter msg :e
your msg is interesting
u want to exit: y
message you have typed : ae
message computer have generated : hellointeresting
vector<string> inputs;
vector<string> outputs;
//............................................
// While loop and s1, s2, ... definitions up here somewhere
if(s1=="a")
{
cout << "your msg is: " << s2 << endl;
inputs.push_back(s1); // Store our input
outputs.push_back(s2); // Store our replacement
}
elseif
// The rest of your replacements here
//..............................................
vector<string>::iterator it;
cout << "message you typed is: ";
for (it = inputs.begin(); it < inputs.end(); ++it)
cout << *it;
cout << "the message computer gave is ";
for (it = outputs.begin(); it < outputs.end(); ++it)
cout << *it;