Citar
Passing a One-Dimensional Array
When a one-dimensional array is passed to a function, the array’s address is passed by
value. This makes the transfer of information more efficient since we are not passing
the entire array and having to allocate memory in the stack for it. Normally, this means
the array’s size must be passed. If we don’t, from the function’s perspective all we have
is the address of an array with no indication of its size.
When a one-dimensional array is passed to a function, the array’s address is passed by
value. This makes the transfer of information more efficient since we are not passing
the entire array and having to allocate memory in the stack for it. Normally, this means
the array’s size must be passed. If we don’t, from the function’s perspective all we have
is the address of an array with no indication of its size.
Los consulto porque tengo una duda con esta parte del libro, si mi traductor no falla dice que las matrices se pasan a funciones por valor, yo tengo entendido que el identificador de una matriz contiene la dirección de memoria del primer elemento o primer byte de la misma, por lo tanto, cualquier modificación que se efectué en la función llamada se ve reflejado en la función llamadora como lo refleja el código que dejo a continuación. -
Código
Es todo, espero que alguien me diga como debo interpretar esto. -
#include <stdio.h> void ab( int a[], size_t tam ); int main( void ){ int a[] = {5, 3, 8, 99, 11}; size_t tam = 5; ab(a, tam); } void ab( int a[], size_t tam ){ a[0] = 1; }
Saludos.