Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. // using ofstream constructors.
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. std::ofstream outfile ("test.txt");
  6.  
  7. outfile << "my text here!" << std::endl;
  8.  
  9. outfile.close();
  10.  
  11. #include <iostream>
  12. #include <fstream>
  13.  
  14. int main() {
  15. std::ofstream o("Hello.txt");
  16.  
  17. o << "Hello, Worldn" << std::endl;
  18.  
  19. return 0;
  20. }
  21.  
  22. #include <iostream>
  23. #include <fstream>
  24. #include <string>
  25. using namespace std;
  26.  
  27. string filename = "/tmp/filename.txt";
  28.  
  29. int main() {
  30. std::ofstream o(filename.c_str());
  31.  
  32. o << "Hello, Worldn" << std::endl;
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement