How can I indent cout output?

c++, out

Solution

You can construct a string to contain a number of repitions of a character:

std::cout << std::string(level, '-') << root->value << std::endl;

Problem

I'm trying to print binary tree ``` void print_tree(Node * root,int level ) { if (root!=NULL) { cout<< root->value << endl; } //... } ``` How can I indent output in order to indent each value with level '-' chars.

Original source