Pointers vs multidimensional arrays

Nasza ocena:

3
Wyświetleń: 511
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Pointers vs multidimensional arrays - strona 1 Pointers vs multidimensional arrays - strona 2

Fragment notatki:

Pointers vs. multi- dimensional arrays • For these definitions: int a[10][20]; and int *b[10]; • Expressions a[3][4] and b[3][4] refer to a single int . • But: - a is a true two-dimensional array with 200 integers - the location of a[row,col] in memory: initial_address + 20 * row + col - b is only an array of 10 pointers - the memory for rows of b should be allocated • Compare the declaration and picture for an array of pointers: char *dnam[] = {"error", "one", "two", "three"}; • with those for a two-dimensional array: char enam[][6] = { "error", "one", "two", "three" }; ... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz