I am using Dev C++ to write to a text file using ofstream but it does not work, I have made a text file in dev c++and saved it and on another source file I wrote the following code:
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main(){
srand(time(0));
ofstream out(“hello.txt”);
for(int i=0;i<100;i++)
out << rand()%1000 << “ “;
out.close();
return 0;
}
However, when I try to compile this code I get an error and it highlights the following in red:
ofstream out(“hello.txt”);
It says hello undeclared.
The tutorials that I am following are from youtube and the programmer is using a Linux operating system, he is using g++, will the code still be the same on all operating systems? because I am using windows 7.