943,947 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3271
  • C++ RSS
Apr 24th, 2007
0

displaying two dimensional array in columns help

Expand Post »
C++ Syntax (Toggle Plain Text)
  1. Hi iam having trouble with displaying my two dimensional array in columns
  2. eg.
  3. |Pie |Peach |Socks
  4. |$3.4 |$5 |$9
  5.  
  6. |Apple |Carrot etc...
  7. |$6.8 |$2
  8.  
  9. <code class="inlinecode">
  10. //for(col = 0; col < COLSIZE; col++)
  11. for(row = 0; row < ROWSIZE; row++)
  12. {
  13. for(col = 0; col < COLSIZE; col++)
  14. //for(row = 0; row < ROWSIZE; row++)
  15. {
  16. ......
  17. </code>
  18. 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.
  19.  
  20. i've tried
  21. <code class="inlinecode">
  22. cout.width(0);
  23. cout <<left<< "|" ;
  24. cout <<item[row][col].Name << endl;
  25.  
  26. cout.width(0);
  27. cout <<left <<"|";
  28. cout.width(0);
  29. cout <<item[row][col].Price << endl;
  30. </code>
  31. with differenct variations but just dosent work :'(
  32. any advice?
  33.  
  34. Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sInFuL69er is offline Offline
9 posts
since Apr 2007
Apr 24th, 2007
0

Re: displaying two dimensional array in columns help

Perhaps other values besides width(0) ?
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Apr 24th, 2007
0

Re: displaying two dimensional array in columns help

C++ Syntax (Toggle Plain Text)
  1. i have tried other values but it jsut pushes the element further away.
  2. i cant get the element besides each other
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sInFuL69er is offline Offline
9 posts
since Apr 2007
Apr 24th, 2007
0

Re: displaying two dimensional array in columns help

use "setiosflags()" and setw() to manipulate the output. dont forget #include <iomanip>
for the decimal you may want to use "setprecision()" hope that helps.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alejo is offline Offline
6 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Can't figure out whats wrong
Next Thread in C++ Forum Timeline: quick little assistance on silly word count!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC