Hi iam having trouble with displaying my two dimensional array in columns
eg.

|Pie     |Peach   |Socks
|$3.4   |$5        |$9

|Apple |Carrot   etc...
|$6.8   |$2

code

//for(col = 0; col < COLSIZE; col++)
 for(row = 0; row < ROWSIZE; row++)
 {
      for(col = 0; col < COLSIZE; col++)
      //for(row = 0; row < ROWSIZE; row++)
      {
  ......

this loops through the array but i cant seem to get it to display the items in the array like how ppl teach other ppl how it looks like.

i've tried

                cout.width(0); 
                cout <<left<< "|" ;
                cout <<item[row][col].Name << endl;

                cout.width(0); 
                cout <<left <<"|";
                cout.width(0);
                cout <<item[row][col].Price << endl;

with differenct variations but just dosent work :'(
any advice?

Thanks

Recommended Answers

All 3 Replies

Perhaps other values besides width(0) ?

i have tried other values but it jsut pushes the element further away.
i cant get the element besides each other

use "setiosflags()" and setw() to manipulate the output. dont forget #include <iomanip>
for the decimal you may want to use "setprecision()" hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.