Created
October 2, 2017 04:48
-
-
Save yoggy/5dfe6e9569b4edbc9df2abfb6e455478 to your computer and use it in GitHub Desktop.
This file contains 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
// | |
// file2string.cpp | |
// | |
// see also... https://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring | |
// | |
#include <fstream> | |
#include <sstream> | |
#include <iostream> | |
int main(int argc, char *argv[]) | |
{ | |
std::ifstream ifs("test.txt"); | |
if (!ifs) { | |
std::cerr << "cannot open file..." << std::endl; | |
return -1; | |
} | |
std::stringstream ss; | |
ss << ifs.rdbuf(); | |
std::cout << ss.str() << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment