found = 0;
while (found!=string::npos)
foundNext = str.find_first_of(".", found+1 ); //numbers between two dots
/// HERE YOUR TRANSFORMATION TAKES PLACE
replace( found, foundNext - found, MY_REPLACEMENT_CHAR );
found = foundNext
- yes there a different ways leading to rome... but all in all it's not an issue
P.S. can "128887012840" go to "acbac" even if there are no full stops ?
mhm...it could...but focus here: 12888 where is the 88 after a twelfe or after the 128? its not clear and you will have problems...another thing...your word folding (how was this called ceasars chiffre or something ancient ;) ) why don't you use chars for chars, like replace every "a" with a "h" and "b" with whatever... then you could do it without full stops since every letter is exactly one byte. Or you'll have to add leading zero's like 128088 which would transform to 128 -> a and 088 -> whatever... but you need some "virtual" full stop then. Like a certain amount of numbers or whatever!
#include <iostream>
#include <string>
#include <Windows.h> //AGAIN? just joking...
usingnamespace std;
int main ()
{
string str ("128.88.70.128.40.");
string searchFor ("128."); // The section beginning here.......
string replaceBy ("a");
string searchFor ("70.");
string replaceBy ("b");
string searchFor ("88.");
string replaceBy ("c"); /// .......ending here
/*
Please take a close look at what you did there! "string" is a TYPE a container, a space in memory or whatever you wanna call it
...now you created such a space in memory and named it "searchFor" afterwards you create another space in memory and named it
the same...now if you call the name it's not clear which one is meant! Another puzzler: what are you going to do if you want to use
more and more letters...are you planning to do the whole thingy 26 times?? Its quite some effort isn't it?
*/
size_t found;
found = str.find( searchFor );
while (found!=string::npos){
str.replace( found, sizeof( searchFor ), replaceBy );
found = str.find( searchFor );
};
cout << str << endl;
return 0;
}