How to read a whole text file at once in C++

1 Answer

0 votes
#include <iostream>
#include <fstream>

using std::cout;
using std::endl;
using std::ifstream;

int main()
{
	ifstream ifs("d:\\data.txt");

	cout << ifs.rdbuf() << endl;

	ifs.close();

	return 0;
}

/*
run:

c c++
c# java php python

*/

 



answered Jun 11, 2018 by avibootz

Related questions

2 answers 327 views
2 answers 263 views
5 answers 433 views
1 answer 168 views
1 answer 553 views
1 answer 174 views
1 answer 214 views
...