my code is supposed to read in a binary file and then save the input to a text file. when i cout << coach i get the output and jibberish
#include <iostream>
#include <string>
#include <cctype>
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
char coach[500];
int i=0;
fstream textFile("coaches.txt",ios::out),
dataFile("binaryFile.dat",ios::in | ios::binary);
if(dataFile.fail() || textFile.fail())
cout << "failed to open! you lose" << endl;
else
{
dataFile.read(reinterpret_cast<char *>(&coach),sizeof(coach));
while(!dataFile.eof())
{
textFile << coach[i];
i++;
}
}
return 0;
}