Where is a file I create with fstream located on my local hard drive?

0 votes
asked Jun 21, 2018 by Kristi Hansen (120 points)
I can create/open a file and write to it using onlinegdb with C++, but I don't know where the file is located.  I'd also like to read from a file on my local drive, but don't know where a.out is running from in order to put the file in the same directory.

2 Answers

0 votes
answered Jun 27, 2018 by Admin (4,200 points)
The files created by program should be visible in editor when they are written.
Here is example for file operation which write file "output.txt" and then deletes it.
https://onlinegdb.com/BJ1BZ8ef7
commented Jun 27, 2018 by Admin (4,200 points)
Just to add more info, you can't refer you local drive files from program.
Because when program is running, it runs on server side which doesn't have access to files on local drive.
However you can refer files which are created in OnlineGDB editor or created by program.
0 votes
answered Sep 1, 2019 by NavarroAndorid (300 points)
In order to read a file from a program you need to include it in the same project.  For example, you can have the data in data.txt and your code y myCode.  You can add additional files to your project using Ctrl + M.  When you list your projects, you will only be able to see the projects names but not the file they contain.  If you want to do so, you can download the project to your computer and unzip it.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...