I am a C++ beginner, so please try and keep it simple as possible! I already found an article on this website on this, but it says "I used help to figure it out", and leaves it at that. Can someone PLEASE tell me why the text file it makes is empty, and how to fill it up with the numbers it generates. Here is the code:
You're trying to open a file, that is alread open:
1 2
ofstream myfile ("feherzaj.txt"); // this constructor opens the file
myfile.open ("feherzaj.txt", ios::out | ios::app ); // then you are explicitly opening it
I imagine you are causing an error or setting an error flag in doing this but not actually closing the file (not completely sure though).
Just remove the line: myfile.open ("feherzaj.txt", ios::out | ios::app );
Also, you're writing C++ so don't use C headers:
1 2 3 4 5
#include <iostream>
#include <cstdio> // don't need this
#include <cstdlib>
#include <ctime>
#include <fstream>