Hey guys , i am trying to write an array into a textfile. Here is the coding...
int main() {
ofstream myfile("report.txt");
int g = 0;
int billy [] = {16, 2, 77, 40, 12071};
for (int n=0 ; n<5 ; n++ )
{
g = billy[n];
myfile << g ;
}
}
The output which comes out in report.txt is...
162774012071
Well , my expected output in report.txt would be.
16
2
77
40
12071
I tried adding "\n" to my statement like this...
myfile << g << "\n" ;
but it dosnt seem to work. Can sombody tell me what is wrong with the way i write the statement into the file?