I have seen a two dimensional array[x][y] to be used in the code like this : array[i]
When it is used like this we mean that we only refer to the row and that the column is zero?
Thank you.
I have seen a two dimensional array[x][y] to be used in the code like this : array[i]
When it is used like this we mean that we only refer to the row and that the column is zero?
Thank you.
Read this, and then check back if you need more help.
Cprogramming.com C guide Arrays for Dummies
I suppose that we can omit x or y if one of the two is zero.
See this code that I get from a book I am reading :
Code:for (i = 0; i < 9; i++) if (planets[i][0] == 'M') printf("%s begins with M\n", planets[i]);
If that were true, then this should have the exact same output:Originally Posted by skiabox
Likewise, this should mean the exact same thing:Code:for (i = 0; i < 9; i++) if (planets[i][0] == 'M') printf("%s begins with M\n", planets[i][0]);
But neither is the case. You can run the former for yourself and verify that the output may be different, and then your compiler should complain about the latter, especially if you turn on warnings.Code:for (i = 0; i < 9; i++) if (planets[i] == 'M') printf("%s begins with M\n", planets[i][0]);
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)