Array with loop.

Hi guys. My first post here. Hopefully not my last :)

I have a little problem. I have an assignment. It goes kind of like this:

You buy a ticket. The user enters 10 values. When the ten values is entered the program asks if you want to buy another ticket. The program will do this until the user does not want to play anymore. Ex. press 3 or something.

Now the problem is that i want to save all these values. That the user enters and save them in a bigger array.

Cuz. If all numbers between 1-50 appears. u win a price.

Hope u guys understand. ATM i dont have anymore code than my loop.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
      do
    {
        cout<<"Pick 10."<<endl;

        for(int i = 0; i < SIZE; i++)

        {
            cin >> number[i];

        }
        cout<<"Again? "<<endl;
        cin >> test;

        if(test !=1)
            continue;

    }
while(test ==1);


Can i copy these number[i] to a new array?
I have tried. But when i do the loop twice. It only overwrite 0-9

//Have a good one!
I think this should work


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
do
    {
        cout << "Pick 10." << endl;

        while(i < SIZE)
        {
            cin >> number[i];
            i++;

        }
        cout<<"Again? "<<endl;
        cin >> test;

        if(test !=1)
            continue;

    }
while(test ==1);


edit: Ok it doesn't work, but the "error" (problem) in your program is
for(int i = 0; i < SIZE; i++)
It say's everytime you start the loop
i = 0
Last edited on
Yep. Exactly. It overwrites all the time. Do u got a solution? Second time the loop runs i want to have i=10..?
Topic archived. No new replies allowed.