Does reading file with fstream not work on xp?

This is a discussion on Does reading file with fstream not work on xp? within the C++ Programming forums, part of the General Programming Boards category; Hi, I have made a program but it doesn't run properly on windows xp? In the program I use fstream ...

Does reading file with fstream not work on xp?

Hi, I have made a program but it doesn't run properly on windows xp? In the program I use fstream to read some files and I'm wondering if this is the problem? If it is what other ways of reading files are there?

>I use fstream to read some files and I'm wondering if this is the problem?
Of course it's Windows, it couldn't possibly be your code could it? I mean, we all know every programmer in the world is perfect. 999 times out of 1000, you're program isn't finding the file because of something you did wrong. I love how everyone places the blame everywhere but themselves. It's like at the automated teller, if something bad happens people scream "stupid machine!" when "stupid user!" would be more accurate.

Wow your an ass, I never blamed it on windows. It works fine one windows 9x so I thought maybe fstream was sort of a dos function and it might now work on xp. Anyway here is my code all it does is read every other line from a file and add it to a list box.

Alright, I'll just check to see if the file opens. Anyways the code that is not working is right there. Becuase when I open the program it downloads a file to c:\cache and then it reads from the file and adds its contents to a listbox. When I run the program it works fine on my computer and my friends but when we tried it on xp it didn't work. However because the file c:\cache was still on the xp machine after the program was run I thought there was a problem with xp reading the file. Anyways sorry for calling you an ass Prelude I'm just saying wasn't really blaming it on the machine.

>Anyways sorry for calling you an ass Prelude
No, it was my fault. I was just letting out my frustration after of long day, it's nothing personal

If the file doesn't open you can check it by saying something along the lines of:

Code:

if ( !file.isopen() )
cout<<"Not a code problem\n";

If the message prints then the program isn't finding the file and you should double check what it's actually looking for. Be sure to check your syntax for opening the file as well, that can cause runtime problems yet still compile without warning or error.

>Hehe i prefer to call the good method lol
As do I when I'm actually processing the file. When debugging however, isopen() is more precise since good() simply tells you that none of the control bits are set. good() doesn't specify whether the file couldn't be read from (ie. not open) or you've simply reached EOF (ie. empty file). Personally, I prefer more detail when debugging a problem.