Format the output from cout

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
      ISBN             Title       Author         Price        Qtty
      ====              =====       ======         =====        ====
A:   0525947671  The Lady and the Unicorn     Chevalier, Tracy     24.47     15
A:   0807282588  Harry Potter and the Goblet of Fire        J. K. Rowling     18
.17     34
A:   0694525421  The Wide Window (A Series of Unfortunate Events, Book 3)
Lemony Snicket        10     11
A:   0310209072  The Purpose-Driven Life          Rick Warren     19.99     10
P:               0525947671  The Lady and the UnicornChevalier, Tracy32.9525
P:               1884822673  365 Simple Science Experiments With Everyday Materi
alsChurchill, E. Richard8.8820
P:               0618256288  What Do You Do with a Tail Like This?Robin Page, St
eve Jenkins10.492
P:               0395938473  The New Way Things WorkMacaulay, David17.3223



Each output item, should be under the column. I'm having big problems trying to get them all lined up. I was given a clue that I should "cut off" text for the title field, as it's running too long and pushing all subsequent lines off. How do I manipulate cout so that the title is limited to a certain number of characters.
1
2
3
4
5
6
#include <iomanip>
#include <iostream>
using namespace std;

cout<<setw(5)<<"the"<<endl;  //print "the" in a field width of 5 characters
cout<<setw(3)<"jafar"<<endl;   //print "jafar" in a field width of 3 characters 

  the
jaf
Topic archived. No new replies allowed.