Created
November 19, 2013 11:24
-
-
Save woxtu/7543972 to your computer and use it in GitHub Desktop.
Read the whole file into std::string in C++.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <fstream> | |
| #include <string> | |
| #include <iostream> | |
| int main() { | |
| std::ifstream stream{"fujiyama.txt"}; | |
| std::string buffer{std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>()}; | |
| std::cout << buffer << std::endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment