Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<string>
- using namespace std;
- string changeS(string s1)
- {
- int size = s1.size() - 3;
- string s2 = s1.substr(0, size);
- s2 = s2 + "***";
- return s2;
- }
- int main()
- {
- cout << "Input a word range>";
- int range;
- cin >> range;
- ifstream fileIn;
- fileIn.open("input.txt");
- if (!fileIn.is_open())
- cout << "Error, file 'intput.txt' not found";
- ofstream fileOut;
- fileOut.open("output.txt");
- //if (!fileOut.open)
- // cout << "Error, file 'output.txt' not found";
- string s1;
- string s2;
- while (!fileIn.eof())
- {
- fileIn >> s1;
- if (s1.size() > range)
- s2 = changeS(s1);
- else
- s2 = s1;
- fileOut << s2 + ' ';
- }
- fileIn.close();
- fileOut.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement