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.

How to read from a file(txt) in c++ online GDB?

+11 votes
asked Jun 14 by Gabriela Correa (220 points)
Hi, so I am confused as to how to connect and use files(txt) that I have saved to my folder. I need to be able to take input from one file and send its output to a second file. How do I do that?

1 Answer

0 votes
answered Jun 24 by Peter Minarik (89,040 points)

It's pretty straightforward. You just do it the same way as you would do it normally, OnlineDGB does not need any specific code. The only thing you need to pay attention to is to upload the file as part of your project so your running code can read it. Just add it to your project so the input (txt) file is right next to your source code. You can do it via the "New File" or "Upload File" icons just left to the  â–ºRun  button.

Here's an example project: https://onlinegdb.com/bfLnTbK0b

Good luck!

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.
...