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.

#include<fstream>...but the data doesn't seem to care to stream!

+2 votes
asked Jan 8, 2018 by Jonjiissmiling c (160 points)
I'm trying to figure out how to write and read data from files using:

#include<fstream>

I wrote a quick program to try to see about creating a file and writing to it, as well as tried a file already created and writing to it, but nothing seems to happen. ???

I've used:

ofstream outputFile;

outputFile.open("Input&Output_TestFileC++.txt"); //just an example...I've also tried using the pathway starting with the C drive....either way, nothing happens.

cout << "Test writing data to file";

outputFile << "Testing.";

outputFile.close();

cout << "Done testing writing data to file.";

The program will run fine, showing me the cout lines that were executed, but when I  try to go to see if a file got created, and or using an existing file to see if the data got written to it...nothing has happened.

How is this fstream, ofstream, and ifstream supposed to be working exactly???

Is this happening because this is an IDE online environment so something else needs to be written in the code a specific way???

1 Answer

0 votes
answered Jan 11, 2018 by anonymous
This IDE doesn't show content of file written by ofstream. But you can read the same file to verify 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.
...