473,383 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

fstream,ifstream,ofstream

i just need to know why ifstream and ofstream are used ??
Jul 28 '15 #1

✓ answered by donbock

Is your question: "Why would anybody use ifstream or ofstream when they could just use fstream?"

4 2487
weaknessforcats
9,208 Expert Mod 8TB
They are part of the C++ Standard Template Library.

I can't answer this until you understand templates and polymorphism.

Until then, you use these if you use the standard library. If you use something else, then you can ignore these.
Jul 28 '15 #2
donbock
2,426 Expert 2GB
Is your question: "Why would anybody use ifstream or ofstream when they could just use fstream?"
Jul 29 '15 #3
yup . i wanna know the clear concepts of ifstream and ofstream,could uh plz tell me a difference briefly...thanks!
Aug 2 '15 #4
donbock
2,426 Expert 2GB
ifstream is for input only.
ofstream is for output only.
fstream is for input, or output, or input mixed with output.

fstream is more powerful, but also more complicated to use.
Aug 2 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Maya | last post by:
Apart from being a pointer, what would be the benefit of using 'std::filebuf' than using the std::fstream? As far as I can see, I would use the same methods in 'filebuf' that I would when using...
1
by: phoenix | last post by:
How can i read a numbers from file.. I created this file like this: int dane, i; std::ofstream plik_z; plik_z.open(nazwa, std::ios::out | std::ios::trunc | std::ios::binary); for (i = 0; i <...
2
by: bballmitch | last post by:
I have the following code #include <cstdlib> #include <iostream> #include <fstream> int score_one=2345, score_two=1800, score_three=1500, score_four=1300, score_five=1100; int ...
3
by: John Smith | last post by:
I would like to write over a file if it exists (or create one if it doesn't exist). The following codes do nothing if the file already exists. How do I get it to overwrite an existing file? ...
2
by: Chris Theis | last post by:
Hello, as stated by the standard the fstream derivatives (ifstream & ofstream) expect a const char* parameter indicating the file name associated with the stream to be opened. I wondered why...
5
by: mastern200 | last post by:
I need to make a program where it can read from a file and write to it. But the problem is, all i can do is read from it and not write to it. This is the code i have so far: # include <iostream>...
7
by: Soneji | last post by:
*sigh* Ok, I have two questions. First, my setup: Win-doze XP-SP2; & Dev-C++ 4.9.9.2; I recently started trying to use 'fstream' to work my input/output, and I noticed that using the...
2
by: mauricesmith42 | last post by:
Sorry i know this is rather large to be posting, but in order to understand the question you have to see all the code //#include <windows.h> //needed for opening folders #include...
2
by: raheelX | last post by:
okay so i want to design a class that will open a text file and manipulate the data in it. and i have to use all these functions from fstream like ifstream, ofstream, seekg etc. the problem is that i...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.