fstream and ofstream difference

can someone tell me the difference between ofstream and fstream? thank you
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.
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&)
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
great thanks Matri X. great explanation. I really need a huge c++ dictionary with every term and its possible use I suppose.
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.

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.

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.

Last edited on
Topic archived. No new replies allowed.