Passing two dimensional arrays to functions

Nasza ocena:

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

Pobierz ten dokument za darmo

Podgląd dokumentu
Passing two dimensional arrays to functions - strona 1 Passing two dimensional arrays to functions - strona 2

Fragment notatki:

Passing t wo-dimensional arrays to functions • At least the number of colums should be defined in the parameter declaration • The number of rows is irrelevant • The function gets a pointer to an array of rows • Passing daytab to a function f : f(int daytab[2][13]) { ... } • or f(int daytab[][13]) { ... } • or f(int (*daytab)[13]) { ... } (a pointer to an array of 13 integers) f(int (*daytab)[13]) { ... } • daytab is a pointer to an array of 13 integers • Parentheses are necessary - brackets [] have higher precedence than * • Without parentheses: int *daytab[13] • would be an array of 13 pointers to integers • In case of multi-dimensional arrays: only the first dimension is free; others have to be specified ... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz