dawrehxyz

Writing to File C++

Oct 7th, 2016
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     ofstream myfile;
  9.     myfile.open("voffi.txt");
  10.  
  11.     for (int a = 1; a < 501; a++)
  12.     {
  13.         myfile << "person(" + to_string(a) + ").\n";
  14.     }
  15.  
  16.     for (int a = 1; a < 501; a++)
  17.     {
  18.         for (int b = a + 1; b < 501; b++)
  19.         {
  20.             myfile << "knows(" + to_string(a) + "," + to_string(b) + ").\n";
  21.         }
  22.     }
  23.  
  24.     myfile.close();
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment