0

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

Edited by pyTony: fixed formating

3
Contributors
3
Replies
5
Views
10 Years
Discussion Span
Last Post by alejo
0
i have tried other values but it jsut pushes the element further away.
i cant get the element besides each other
0

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

This topic has been dead for over six months. 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.