J
Joe
Hello -
I use a ifstream to open a file in my code. I read through it using
getline() and then I close() it. Later in the code I try to open the
same file but it fails. Here is the code:
ifstream InputFile;
char Line[MAXcharLine + 1]; // MAXcharLine = 512
InputFile.open("XXX.dat");
if (InputFile == NULL)
{
// ERROR
}
while (InputFile.getline(Line, MAXcharLine))
{
// DO STUFF
}
InputFile.close();
....
InputFile.open("XXX.dat")
if (InputFile == NULL)
{
// This is where the code fails!
}
What is wrong that it doesn't work? If I don't do the getline() then
it works fine.
Thanks a lot,
Joe
I use a ifstream to open a file in my code. I read through it using
getline() and then I close() it. Later in the code I try to open the
same file but it fails. Here is the code:
ifstream InputFile;
char Line[MAXcharLine + 1]; // MAXcharLine = 512
InputFile.open("XXX.dat");
if (InputFile == NULL)
{
// ERROR
}
while (InputFile.getline(Line, MAXcharLine))
{
// DO STUFF
}
InputFile.close();
....
InputFile.open("XXX.dat")
if (InputFile == NULL)
{
// This is where the code fails!
}
What is wrong that it doesn't work? If I don't do the getline() then
it works fine.
Thanks a lot,
Joe