Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. void FileWriter::WriteToFile(std::string * fileLocation, std::string * fileText)
  2. {
  3. std::ofstream thisFile;
  4. thisFile.open (* fileLocation);
  5. thisFile << * fileText;
  6. thisFile.close();
  7. }
  8.  
  9. std::string FileWriter::ReadFromFile(std::string * fileLocation)
  10. {
  11. std::string strToReturn;
  12. std::string line;
  13. std::ifstream thisFile(* fileLocation);
  14. if (thisFile.is_open())
  15. {
  16. while (std::getline(thisFile, line))
  17. strToReturn += line + "\n";
  18. thisFile.close();
  19. }
  20. else
  21. std::cout << "Invalid file location" << std::endl;
  22. return strToReturn;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement