Crash and trouble Inputing values in an pointer-to-int-array

1
2
3
4
5
6
7
8
9
10
11
12
    const int months = 12;
    char * Month[months] =
    {"January", "February", "March", "April", "May", "June", "July", "October", "November", "December"};
    int *Books[months];
    int temp;

    for (int i = 0; i < months; i++)
    {
        cout << "Enter the number of books sold in " << Month[i] << ": ";
        cin >> temp;
        Books[i] = temp;
    }


Right now im trying to make my loop cycle through the month each time, and input a value into a pointer-to-int-array each time, then changing the month afterwards.

Trouble is, right now I'm not sure about the input part, and using cin to input values. How do I go about doing this, and also its crashing, and I cant determine why.
On line 4 you are making an array of int*. I assume you want to read in numbers, so you should make it an array of simply int.
Yeah I figure that out shortly after posting this, took me 30 min of staring, posted this, and realized why am I making a pointer to an array.
Topic archived. No new replies allowed.