I haven't got any luck finding why this program wouldn't work.
Here's the code.
int main (void)
{
ifstream file;
char *streamer = NULL;
file.open("now.txt", ios::in | ios::binary);
if (file.is_open())
{
while (!file.eof())
{
streamer = new char[33];
cout << "Prestream: " << streamer << endl;
file.read(streamer, 32);
cout << "gcount: " << file.gcount() << endl;
cout << strlen(streamer) << endl;
cout << streamer << endl << endl;
delete [] streamer;
}
}
}
The problem is when the file get pointer is almost at the end,
the program's supposed to take only the remaining characters,
so if there are only 12 characters left, streamer will only have 12 characters, the problem is that streamer will still have 32, the mysterious 20 characters coming from the previous read() operation.
Any help would be appreciated.