Can you declare whole rows of a multi-dimensional array at one time? or do you have to go through and individually declare each spot one at a time?
Can you declare whole rows of a multi-dimensional array at one time? or do you have to go through and individually declare each spot one at a time?
Code:int x[][5] = { { 1, 2, 3, 4, 5 }, { 2, 4, 6, 8, 10 } };
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
I cant seem to get it to work. What are the second group of numbers for?
Try this:
Code:#include <iostream> using namespace std; int main(void) { int x[2][5] = { { 1, 2, 3, 4, 5 }, { 2, 4, 6, 8, 10 } }; for (int i = 0; i < 2; i++) for (int j = 0; j < 5; j++) cout <<"x["<<i<<"]["<<j<<"] = " <<x[i][j] <<endl; return(0); } /* Output: x[0][0] = 1 x[0][1] = 2 x[0][2] = 3 x[0][3] = 4 x[0][4] = 5 x[1][0] = 2 x[1][1] = 4 x[1][2] = 6 x[1][3] = 8 x[1][4] = 10 */
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]