For my (online) programming class, I have to format certain output in columns using setw. I am having trouble understanding how to do this. My professor says that I am supposed to be creating columns, not counting characters to align things. I haven't been able to find any examples of this online. I've been doing something similar to this to align things:

cout << setw(10) << someVarible << setw(15) << someOtherVarible << setw(20)
     << anotherVarible;

Apparently, this is not the way I am supposed to do this, and I've gotten points taken off on my assignments because of this. How exactly to I create columns using setw? Any help would be greatly appreciated.

Edited by segadude: Corrected spelling

2 Years
Discussion Span
Last Post by NathanOliver

Silly question but can't you have your teacher explain what you should have done not to have points taken off? It is hard for us to know what he is thinking.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.