Skip to content

Instantly share code, notes, and snippets.

@faustoct1
Last active July 25, 2022 12:49
Show Gist options
  • Save faustoct1/3a3927bae56b1e53a9e67d1513ffb2ea to your computer and use it in GitHub Desktop.
Save faustoct1/3a3927bae56b1e53a9e67d1513ffb2ea to your computer and use it in GitHub Desktop.
Passando array com ponteiro por referência para função em C
/*
Compilar: gcc -o array array.c
Executar: ./array
*/
#include <stdio.h>
void preencheArray(int* array){
for(int i=0;i<5;i++){
array[i] = i+1;
}
}
void printArray(int* array){
for(int i=0;i<5;i++){
printf("index[%d]=%d\n",i,array[i]);
}
}
int main(){
int i=0;
int array[5];
preencheArray(array);
printArray(array);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment