Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <algorithm>
- void CustomReplace(std::string& s, char* oldc, char* newc, int numtoreplace) {
- for (int i = 0; i < numtoreplace; ++i) {
- std::replace(s.begin(), s.end(), oldc[i], newc[i]);
- }
- }
- int main()
- {
- char LettersArray[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
- char SpaceArray[26] = { '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_' };
- std::string NameArray[3] = { "ayoub", "is", "nothing" };
- int LettersSpaceVariable;
- int NameVariable;
- int RandomName;
- RandomName = rand() % 3;
- std::string TheRandomName = NameArray[RandomName];
- CustomReplace(TheRandomName, LettersArray, SpaceArray, 26);
- //std::replace(TheRandomName.begin(), TheRandomName.end(), LettersArray, SpaceArray);
- std::cout << TheRandomName << std::endl;
- std::string input;
- std::cin >> input;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement