Thursday, 15 January 2015

C++: Repeat output i times without an explicit loop -



C++: Repeat output i times without an explicit loop -

is there way without loop writing less code possible:

for (int = 0; < 10; i++) std::cout << 'x';

like in python:

print 'x' * 10

std::generate_n( std::ostream_iterator<char>(std::cout, ""), 10, [](){ homecoming 'x'; } );

c++

No comments:

Post a Comment