fstream and ofstream difference

Sep 16, 2013 at 3:57am
can someone tell me the difference between ofstream and fstream? thank you
Sep 16, 2013 at 4:01am
They are both filestreams.
fstream objects opens a file in user-specified mode, it could be to read from, write to, and(or)in binary mode.
ofstream objects opens a file only for output mode.
Sep 16, 2013 at 4:10am
thanks, how come when I change an fstream to an ofstream I get an error no matching function for call to getline (::std:ofstream&, std::stream&)
Sep 16, 2013 at 4:14am
That depends on what arguments you supply to std::getline()
std::getline() does not take TWO std::fstream or std::istream object but rather an std::istream or std::ifstream object with another data type(int, const char *, std::string etc). I guess you supplied it two wrong arguments.

EDIT: I omitted the word "TWO"
Last edited on Sep 16, 2013 at 4:24am
Sep 16, 2013 at 4:58am
great thanks Matri X. great explanation. I really need a huge c++ dictionary with every term and its possible use I suppose.
Sep 16, 2013 at 9:22am
I really need a huge c++ dictionary with every term and its possible use I suppose.

A good starting point would be the search box at the top of this page. It usually gives the reference page for standard C++ terms.
Sep 16, 2013 at 11:13am
http://www.cplusplus.com/doc/tutorial/files/

If you're looking for some great documentation the above link in my mind is the best.

Also refer here if you need more help.
http://www.cplusplus.com/reference/
Sep 16, 2013 at 12:09pm
Hi,

You will get the easy solutions for the different programs, here is the link try this site.

It offers free Tutorials and Let Me Try online Editor for C, C++, C#, JAVA, HTML, CSS, JavaScript and more.

Check following link for your answer.

http://www.cbtsam.com/cppl1/cbtsam-cppl1-011.php
Last edited on Sep 18, 2013 at 5:21am
Topic archived. No new replies allowed.