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.

Please how can I read to and from a file on this platform? ( using “fstream” in C++)

0 votes
asked Feb 25, 2019 by Haastrup Kehinde (120 points)

2 Answers

0 votes
answered Feb 28, 2019 by Noah DeBord (310 points)
I can't understand what you mean... Please be more clear.
0 votes
answered Mar 1, 2019 by Armand Ilas (140 points)
In order to add a new file, you can use the shortcut Ctrl-M.

If you mean how to use fstream, then you have to:

#include <fstream>

//after using namespace std; you have to put the next lines:

ifstream f("file.in");

ofstream g("file.out");///the name "file can be changed to whatever name you want, as long as you create files with the same names

//now you can use f exactly like you would use cin and g like cout

//note that instead of f you can put fin or whatever you like;

//the same goes for g
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.
...