Question

1. a) To read anything from a file stream, you need to open it. Give one...

1.

a) To read anything from a file stream, you need to open it.

Give one example in C++ code of opening a file stream.

b) How do you know whether the stream has failed in C++?

c) In your own words, what is a stream manipulator in C++?

0 0
Add a comment Improve this question Transcribed image text
Answer #1
a)
ifstream in;    // declaring a variable to read data from file
in.open("filename");    // open file using open function

b)
there are two ways to check if a file is properly opened or not.
is_open, fail functions
is_open function gives a value of true if file is successfully opened
file function gives a value of true, if opened a file was failed

c)
<< is insertion stream manipulator
and >> is extraction stream manipulator

<< is used to write data to stream
and >> is used to read data from a stream
Add a comment
Know the answer?
Add Answer to:
1. a) To read anything from a file stream, you need to open it. Give one...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT