123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
#include <iostream> #include <fstream> #include <string> int main() { std::string text; std::fstream file; int posStart, posEnd; file.open("test.txt"); if (file.is_open()) { std::cout << "The file is open." << std::endl; posStart = file.tellp(); //0 int i = 0; while (getline(file, text)) { i++; std::cout << text << "\n"; std::cout << text.size() << " size \n"; std::cout << i << "\n"; posEnd = file.tellp(); for (int temp = 0; temp < text.size(); temp++) { text[temp] = ~text[temp]; } file.seekp(posStart); std::cout << "writing!!!!" << text << std::endl; file << text; posStart = posEnd; }//while } else { std::cout << "Failed." << std::endl; } file.close(); std::cin.ignore(); std::cin.get(); return 0; }
line one. line 2. line 3.