Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

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 (5,100 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 (5,100 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.
commented Jan 27 by mallikb100 (100 points)
Yes correct. to test it I have write file to sample.txt using ofstream. I can see a tab created with file name in onlinegdb(on server).
Created another program to read this file using ifstream it printed on console.
This confirms the file is on the onlinegdb server you can write and read in two different sessions.
0 votes
answered Sep 1, 2019 by NavarroAndorid (360 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.
...