I have tried running this code in my school and it works like a charm but when I got home, this piece of code suddenly gets error. Can somebody enlighten me about what happened to my code? Is there something that I should correct or add in my code? edited : There were build errors in the code.
#include <iostream>
#include <fstream>
#include <string>
ofstream fileObject;
using namespace std;
int main() {
    string username[5];
    cout << "Enter username: ";
    for (int i = 0; i < 5; i++) {
        getline(cin, username[i]);
    }
    fileObject.open("open.txt", ios::app);
    for (int x = 0; x < 5; x++) {
        fileObject << username[x] << endl;
    }
    fileObject.close();
    return 0;
}
 
     
    