dawrehxyz icon

Writing to File C++

dawrehxyz | PRO | 10/07/16 01:29:19 PM UTC | 0 ⭐ | 343 👁️ | Never ⏰ | []
C++ |

420 B

|

None

|

0 👍

/

0 👎

#include <iostream>
#include <fstream>
#include <string>
 
using namespace std;
 
int main() {
    ofstream myfile;
    myfile.open("voffi.txt");
 
    for (int a = 1; a < 501; a++)
    {
        myfile << "person(" + to_string(a) + ").\n";
    }
 
    for (int a = 1; a < 501; a++)
    {
        for (int b = a + 1; b < 501; b++)
        {
            myfile << "knows(" + to_string(a) + "," + to_string(b) + ").\n";
        }
    }
 
    myfile.close();
    return 0;
}

Comments