Last active
July 25, 2022 12:49
-
-
Save faustoct1/3a3927bae56b1e53a9e67d1513ffb2ea to your computer and use it in GitHub Desktop.
Passando array com ponteiro por referência para função em C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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