RosettaCodeData/Task/Write-float-arrays-to-a-text-file/C++/write-float-arrays-to-a-text-file-1.cpp
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

13 lines
541 B
C++

template<class InputIterator, class InputIterator2>
void writedat(const char* filename,
InputIterator xbegin, InputIterator xend,
InputIterator2 ybegin, InputIterator2 yend,
int xprecision=3, int yprecision=5)
{
std::ofstream f;
f.exceptions(std::ofstream::failbit | std::ofstream::badbit);
f.open(filename);
for ( ; xbegin != xend and ybegin != yend; ++xbegin, ++ybegin)
f << std::setprecision(xprecision) << *xbegin << '\t'
<< std::setprecision(yprecision) << *ybegin << '\n';
}