Disregard

I don't know how to delete this post.
Last edited on
Just save the file on C:\Temp and then replace "telephone.dat" to "C:\\Temp\\telephone.dat". It will open the file. If it fails, the else statement is executed.

Once you get the file to display on the console, you can modiy the main function as follows:

int main(const int argc, const char * argv[])

you can pass in the full file path to your application from the command line. You check if argc is greater or equal to 2. If it is, then argv[0] is your full path of your app and argv[1] is your file you want to read.

For visual studio, you can add it under Configuration Properties -> Debugging -> Command Arguments.
Last edited on
Well I'm not having any trouble with the file opening. Whenever I change the name of the file it will run my error..I'm just having a problem with getting it to display when the program is run.
What do you mean "getting it to display?"
There is three items in the file.
Tony Gaddis 1234567890
Barack Obama 2024561111
James Bond 0070070007

When the program runs those three things are supposed to pop up. but nothing does.

I just see the "Press any key to continue..."

but if I change the name to "telephne.dat" or something different than the file name, the error message will display.
I tried your code with your sample data and it works for me in my VS 2005.

From what you're describing me, it sounds like it has reached to the end of the file. Try to seek to the beginning of the file:

inputFile.seekg (0, inputFile.beg);

Add that line of code before the while loop statement. It may work.
No.. :(
Still getting the Press enter to continue...
Use the VS debugger and step through the code. Check what happens when you reach at the while statement.
Topic archived. No new replies allowed.