fstream - STL C++

basic_ifstream<C,T>::close()

Declaration

void basic_ifstream<C,T>::close();

Description

This is the close function for the basic_ifstream class template.

Header Include

#include <fstream>

Example

#include <iostream>
#include <fstream>

int main() {
	using namespace std;

	// Open the input file stream for reading
	basic_ifstream<char> qXoaXFile;
	qXoaXFile.open("XoaX.txt");

	if (qXoaXFile.is_open()) {
		// Read from the file
		cout << "Read from file: " << qXoaXFile.rdbuf() << endl;
		qXoaXFile.close();
	} else {
		cout << "\"XoaX.txt\" failed to open" << endl;
		return -1;
	}

	// Keep the window open
	cin.get();
	return 0;
}

Output

basic_ifstream<C,T>::close() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.