954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

displaying two dimensional array in columns help

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 &lt; COLSIZE; col++)
     for(row = 0; row &lt; ROWSIZE; row++)
     {
          for(col = 0; col &lt; COLSIZE; col++)
          //for(row = 0; row &lt; ROWSIZE; row++)
          {
      ......</code>  
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 <code>                    cout.width(0); 
                    cout &lt;&lt;left&lt;&lt; &quot;|&quot; ;
                    cout &lt;&lt;item[row][col].Name &lt;&lt; endl;
                  
                    cout.width(0); 
                    cout &lt;&lt;left &lt;&lt;&quot;|&quot;;
                    cout.width(0);
                    cout &lt;&lt;item[row][col].Price &lt;&lt; endl;</code> 
with differenct variations but just dosent work :'( 
any advice?

Thanks
sInFuL69er
Newbie Poster
9 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

Perhaps other values besides width(0) ?

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 
i have tried other values but it jsut pushes the element further away.
i cant get the element besides each other
sInFuL69er
Newbie Poster
9 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

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

alejo
Newbie Poster
6 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You