I've been coding for a little over a month now and I have decided to give 2d arrays out. One thing I am getting confused with is how to assign values to the second portion. Like if I have arr2D[x][y] how do I assign inputs to the [y] portion. Since I would have a loop of inputs for [y] until it does not meet condition.
cout<<"Please enter in how many rolls your input files contains."<<endl;
for(y=0;y<2;y++)//cause this program is taking values of 2 dice rolls so only 2 elements
myfile>>arrDice[x][y];//dont know how to input just for[y] so stating what I am trying to input data into.
The file I am using is layed out in a format of:
If you could give me an example of how you would input data into the second portion of a 2d array that would be of great help! Thank you to all taking time to read and help me with this issue.
Makes a really unstable program. If you want to use that you need a dynamic array which made through pointers.
But as to actually assign value it is really simple say if we use the example
1 2 3 4 5 6 7 8
int main ()
int thearray ;
thearray  =2;
What this does is assign the value to the index value of 2 and 2. Or to better think about it is to think about a box and divide it in quarters and each of these quarters is representation of the array. So it would be like this...
Upper left of the box = thearray 
Bottom left of the box = thearray 
and so forth
So going back to that coding above we placed the value two into the bottom right hand spot of the box. You follow this kind of logic when it come to 2d arrays. Hope that helps and furthermore, you should check out the page on arrays as well if haven't done so already.
i haven't tried to compile yet since I couoldn't think of proper way to assign value, but thank you for showing the way! Makes so much sense when thought out as a grid =D.
Now time for me to read up on dynamic arrays apparantly =)
// 2D array.cpp : main project file.
for (int x=0;x<3;x++)
cout << "Enter an integer value for arr2D[" << x << "][" << y << "] " ;
cin >> arr2D[x][y];
// Now print out the array
cout << endl << "The values entered were:" << endl;
cout << arr2D[x][y] << " ";
cout << endl; // Go to next line, for next set of values