Setting nice text columns

I'm displaying a formatted dictionary, that uses two strings contained in a struct. One is word, the other is def. How can I format my output so that the def string retains its setw value? For instance,

I have this:
**word**            **Definition**
chair               A wooden thing you sit on with lots of extra words here to
 show what I'm talking about... 


I want this:
**word**            **Definition**
chair               A wooden thing you sit on with lots of extra words here to
                    show what I'm talking about...


Here is the code snippet that does this.

1
2
3
4
void print_it( const std::string& word, const std::string & def)
{
    std::cout << left << setw(10) << word << setw(30) << def << endl << endl ;
}


I should probably know this, but... I don't.
Last edited on
Topic archived. No new replies allowed.