Input string text into string array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  
        /*assume array is already initialized and declared and is of array type string.*/

        int i = 2;
        int j = 1;
        string newvalue;
        cout<<"Current value at array[i][j] is "<<array[i][j]<<endl;
        cout<<"Enter new value "<<endl;
        cin>>newvalue;
        array[i][j]= newvalue; //PROBLEM IS IN THIS LINE.
        cout<<endl;

        cout<<array[i][j]<<endl;

Hi guys,

I'm having lots of trouble with storing a cin string text into a string array.

It just seem that after I cin newvalue, the program crashes.

Is this way of storing it considered illegal? I'm just a beginner with 5 months of coding experience in C++.

Thanks in advance for the input.
What size did you make the array when you declared it?
Topic archived. No new replies allowed.