getting number of rows from 2D array

September 14, 2011 at 18:37:42
Specs: Windows 7
hey guys how do I show the exact number of rows in a 2D array? let's says I want to have array[10][20] that means I can have a maximum of 10 strings with a maximum of 19 characters in each string, but I only have 8 rows of strings filled up, but how do I show that there's 8 rows in my array?

can I try:

int size=sizeof(array);

will this work?

See More: getting number of rows from 2D array

Report •

September 14, 2011 at 21:49:57
sizeof(array) will give you the total size of your array [10][20]; it's up to you to keep track of how many "strings" you've actually stored.

int i, idx = 8;

for(i=0; i < idx; ++i) {
   /* do something with array[i]  */

something like that.

Report •
Related Solutions

Ask Question