Skip to content

Instantly share code, notes, and snippets.

@douglascamata
Created March 20, 2011 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglascamata/878609 to your computer and use it in GitHub Desktop.
Save douglascamata/878609 to your computer and use it in GitHub Desktop.
matrizes com ponteiros
#include <stdio.h>
#include <stdlib.h>
void le_numeros(int **matriz){
int i;
for(i=0; i<10; i++){
printf("Entre com um número: ");
scanf("%d", (*matriz+i));
}
}
void imprime_numeros(int **matriz){
int i;
printf("\nOs números armazenados são: ");
for(i=0; i<10; i++)
printf("%d ", *(*(matriz)+i));
}
int main(){
int *matriz;
matriz = (int *) malloc(10*sizeof(int));
le_numeros(&matriz);
imprime_numeros(&matriz);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment