fstream << a(0) << …<<a(n) vs fstream << a(0); … fstream <<a(n);

  c++, fstream

Given a number of variables containing data a(1) – a(n), what is the best way to write this data to a file using std::fstream and what are the differences?

if I have an open std::fstream to a file do I use

std::fstream << a(0) <<"t" <<
             << a(1) <<"t" <<
             ...
             << a(n) <<"n";

or

std::fstream << a(0);
std::fstream << "t";
...
std::fstream << a(n);
std::fstream << "n"; 

is there a functional or perfomance difference?

Source: Windows Questions C++

LEAVE A COMMENT