What does the below statement do in c++, i have seen these being used in alot of programs.

1.ifstream ipfile;
2. ipfile.fopen(ipfname);
3. char buffer[BUFLEN];
4. cout.put('\a');
5.

Recommended Answers

All 2 Replies

line 1: create an ifstream object to read from a file.

line 2: Opens a file for reading

line 3: declares a character array of BUFLEN number of bytes.

line 4: sounds the internal computer speaker, assuming it has one.

Second statement is wrong. You must have not seen it in many codes.
There is no function called fopen for the istream class.
This line should have been:
ipfile.open(ipfname);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.