Skip to content

Instantly share code, notes, and snippets.

@joastbg
Last active October 19, 2018 04:41
Show Gist options
  • Select an option

  • Save joastbg/eed75a6404272156aa7a to your computer and use it in GitHub Desktop.

Select an option

Save joastbg/eed75a6404272156aa7a to your computer and use it in GitHub Desktop.
Read and parse doubles from file
#include <iostream>
#include <iterator>
#include <fstream>
#include <algorithm>
int main () {
std::ifstream infile("example.txt");
std::istream_iterator<double> iit (infile);
std::copy(iit, std::istream_iterator<double>(),
std::ostream_iterator<double>(std::cout, "\n"));
return 0;
}
#include <iostream>
#include <iterator>
#include <fstream>
#include <algorithm>
void main() {
std::wifstream infile(L"threadpool.cpp");
std::istream_iterator<std::wstring, wchar_t> iit(infile);
std::copy(iit, std::istream_iterator<std::wstring, wchar_t>(),
std::ostream_iterator<std::wstring, wchar_t>(std::wcout, L"\n"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment