Hi i have the task to type in the following numbers 111000 in a string, and then type this format in another string something ... something ...
the final string shout be the following: something 111 something 000
i have written the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <string>
usingnamespace std;
int main()
{
string ss; //do not use it here
string s;
cout << "write some 1 and 0 "<< endl;
getline (cin, ss);
cout << "write some . (dots) and some text"<< endl;
getline (cin, s);
replace( s.begin(), s.end(), '.', '1' );
cout << s << endl;
system("pause");
return 0;
}
with this code i am testing replace(), but I still cant find any solution to implement string ss so that the dots can be replaced by the content of ss string and not by '1'.
I think you may have to use a loop to examine each individual character of s to see if it is '.' and replace that character with successive characters from ss.
Exit the loop when the last character of either ss or s has been reached.