H'H H'H - 1 year ago 81
C++ Question

how to multiple space lines in the output file in C++

I am wondering if there is any short command in C++ for adding multiple space lines in the output? (I know about "endl" and "\n")

thanks for any help in advance.

Answer Source

No there are no special facilities for adding multiple space lines. you can do this:

std::cout << "\n\n\n\n\n";

or this

for (int i = 0; i < 5; ++i)
  std::cout << "\n";

or implement your own operator*

std::string operator*(std::string const &s, std::size_t n)
  std::string r;
  r.reserve(n * s.size());
  for (std::size_t i = 0; i < n; ++i)
    r += s;
  return r;

std::cout << (std::string("\n") * 5);

finally, recommended solution:

std::cout << std::string( 5, '\n' );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download