Thread: Creating columns with setw without counting characters

  1. #1
    Registered User
    Join Date
    Jul 2015
    Posts
    1

    Creating columns with setw without counting characters

    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:

    Code:
    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? Example code would be helpful. Any help would be greatly appreciated.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Why not ask your professor for an example of what is expected?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array counting Rows and Columns:
    By jocdrew21 in forum C Programming
    Replies: 7
    Last Post: 07-21-2013, 02:07 PM
  2. counting characters
    By s_jsstevens in forum C Programming
    Replies: 9
    Last Post: 04-17-2007, 02:27 PM
  3. Counting characters
    By jmajeremy in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2006, 10:14 AM
  4. Counting Characters HELP !!
    By Zozo17 in forum C Programming
    Replies: 2
    Last Post: 03-01-2005, 08:00 PM
  5. Counting characters
    By Calavera in forum C Programming
    Replies: 5
    Last Post: 10-01-2004, 10:15 AM