Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- void transfer(char symbol, std::string first, std::string second) {
- std::ifstream file(first);
- std::ofstream output(second, std::ios::out | std::ios::trunc);
- if (!file.is_open() || !output.is_open()) return;
- std::string line;
- while (true) {
- int i = file.get();
- if (i <= 0) break;
- char c = (char)i;
- line += c;
- if (c == '\n') {
- if (std::find(line.begin(), line.end(), symbol) != line.end())
- output << line;
- line.clear();
- }
- }
- file.close();
- output.flush();
- output.close();
- }
- int main() {
- transfer('0', "hello.txt", "world.txt");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement