I have some code that is supposed to dig right into a file and return the text it finds (it's a big file). Unfortunately for me it compiles properly but crashes in the actual program; this is what leads me to beleive the problem is with the heap. My code is below:
Code:
char* file_get(char* fdest)
{
fstream file(fdest,ios::in);
char* temp = new char;
*temp = 0;
if(file.is_open())
while(!file.eof())
file.getline(temp, 1000000);
file.close();
return temp;
}
int main()
{
char* temp = file_get(dest);
cout << temp;
delete temp;
return 0;
}
I have included a required headers etc. etc. So what am i doing wrong?