![]() |
| ||
| A bit of a problem with Arrays I am a bit confused. I am trying to make a program that will take the choices you make and display them all simular to this: Item 1. Sword Item 2. Shield Item 3. Potion Item 4. Potion but when I try to run it it looks more like this first Item 1. Sword then Item 1. Shield Item 2. Shield then Item 1. Potion Item 2. Potion Item 3. Potion and so on and so forth. I am unsure of what i am doing wrong. #include <iostream> please help if you can. |
| ||
| Re: A bit of a problem with Arrays You aren't storing the items anywhere? All you are doing is increasing the number of items bought each time. And printing the latest item off. If you buy item 5, 6 and 1. You need to store this somewhere, maybe in another array? Then print out this array. Not the itemlist array. Currently this is what you are doing: Add Item? - Yes Increase numItems Which Item? - x FOR LOOP - FOR numItems, print out Item x What you want is: Add Item? - Yes Which Item? - Item = 2 Bag[numItems] = Item numItems++ for(i = 0; i < numItems; i++) .... print Bag[i] |
| ||
| Re: A bit of a problem with Arrays Ok, i see what you mean. but it doent seem to be working, maybe i am not writing it correctly. here's what i'm trying: char Items[NumItems][StringSize] = |
| ||
| Re: A bit of a problem with Arrays #include <iostream> Try it. I am eating dinner in a min so cba :) |
| ||
| Re: A bit of a problem with Arrays Im sorry to say it, butwhen I pasted your program to my compiler, i had the same problem when i started. Have you any other thoughts? please. |
| ||
| Re: A bit of a problem with Arrays #include <iostream> Done. However you should look over this, I'm new with C++ but fixed it in 2min. I was missing a brace or 2 and a variable++. |
| ||
| Re: A bit of a problem with Arrays Ah Ha! it works, you have my thanks. The bunny thanks you too. 8D |
| All times are GMT -4. The time now is 7:23 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC