I have the following function, which writes a vector
to a CSV file:
#include
#include
#include
#include
As you observed, copying via std::copy
doesn't do the trick, one additional ,
is output. There is a proposal that will probably make it in the future C++17 standard: ostream_joiner, which will do exactly what you expect.
However, a quick solution available now is to do it manually.
for(auto it = std::begin(*pdata); it != std::end(*pdata); ++it)
{
if (it != std::begin(*pdata))
std::cout << ",";
std::cout << *it;
}