Advertisement
RCherry93

Jason File Example

Apr 24th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. string class1 = "Warrior";
  9. string class2 = "Mage";
  10. string class3 = "Thief";
  11.  
  12. ofstream file;
  13.  
  14. file.open("classes.txt", ios::out);
  15.  
  16. // Write the value for class1 which is "Warrior" to the file
  17. file << class1;
  18.  
  19. // Do the same for class2 "Mage"
  20. file << class2;
  21.  
  22. // and last for class3 "Thief"
  23. file << class3;
  24.  
  25. // Remember to close the file
  26. file.close();
  27.  
  28. // This method must return something.
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement