Cannot get file to open?

Feb 10, 2014 at 6:04pm
I am trying to get a simple html file to display but I cannot get the file to actually open. I have the file in the same place as my program files but it will not open. Is it a problem with my code or is it something else?

The file name is just "test"
Last edited on Mar 24, 2014 at 6:19pm
Feb 10, 2014 at 8:16pm
> I have the file in the same place as my program files
http://www.gnu.org/software/libc/manual/html_node/File-Name-Resolution.html


Also, if the file is in an invalid state, I think that you need to inFile.clear(); before attempting anything.
Feb 10, 2014 at 9:50pm
I tried that, same result. The file name is "test"
Feb 10, 2014 at 10:17pm
The problem may be related to how you execute the application.
Paste the commands and user input.

Also, provide a directory listing to see that `test' file.
Feb 11, 2014 at 12:48am
Have you tested it with other files?

edit: i just checked it and it works fine with the sample file i used.

albeit i had to add a cout/cin to check my results.. maybe you overlooked that?
Last edited on Feb 11, 2014 at 12:51am
Feb 11, 2014 at 2:12am
I have tried it with multiple other text files but it's still not working?

Where does the .txt file need to be saved in order to open it?
Feb 11, 2014 at 3:28am
> Where does the .txt file need to be saved in order to open it?
If you simply write `test', then the file ought to be in the current working directory.
Note that the `working directory' is not the same as the `directory where the executable is in'.
Feb 11, 2014 at 3:35am
What is the difference between the `working directory' and the `directory where the executable is in'?
Feb 11, 2014 at 3:56am
$ ls /usr
bin include lib local sbin share src
$ cd /usr
$ pwd
/usr
$ ls
bin include lib local sbin share src
$ /usr/bin/ls
bin include lib local sbin share src
$ bin/ls
bin include lib local sbin share src
`ls' resides in `/usr/bin/', however the runs refer to `/usr' because that's the current working directory (as showed by `pwd')
Last edited on Feb 11, 2014 at 3:56am
Feb 11, 2014 at 4:16am
So you're saying my file is in the wrong place?

My .txt and .cpp files are saved in (C:/), and that is wrong?
Last edited on Feb 11, 2014 at 4:21am
Feb 11, 2014 at 4:22am
Feb 11, 2014 at 9:10pm
My "test" file is saved in the same place as my ".cpp" source file but I'm still having issues. I have tried this on multiple computers as well.
Feb 11, 2014 at 10:14pm
I had same problems in past. My mistake was not adding .txt or .xl or whatever file I was trying to open. i.e. lets say your "test" file is a text document. so you need to enter input like this: test.txt
Topic archived. No new replies allowed.