I'm having a absolute nightmare at the moment. I'm trying to write a char array to a text file. This works fine but I want to be able to format so that each element is on a different line. At the moment it is all on one line in the text file. I have tried different things such as putting:
file << parent[i] << endl;
But all this does is print out random symbols or whatever they are which are not supposed to be. The working code is just printing the correct data in one line, which is below:
void writeToFile()
{
ofstream file;
file.open("test.txt", ios::app);
file << "\n" << endl;
for(int i = 0; i < arraySize; i++)
{
file << parent[i];
}
file.flush();
file.close();
}
Thanks,
Mark

New Topic/Question
Reply



MultiQuote











|