fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. int tam;
  6. printf("Tamanho do vetor: ");
  7. scanf("%d", &tam);
  8. int *vet = malloc(tam * sizeof(int));
  9.  
  10. printf("\nEntre com os elementos do vetor:\n");
  11. for (int i = 0; i < tam; i++) scanf("%d", &vet[i]);
  12. printf("Elementos do vetor:\n");
  13. for (int i = 0; i < tam; i++) printf("%d ", vet[i]);
  14. }
  15.  
  16. //https://pt.stackoverflow.com/q/318510/101
Success #stdin #stdout 0s 4196KB
stdin
10
1
2
3
4
5
6
7
8
9
10
stdout
Tamanho do vetor: 
Entre com os elementos do vetor:
Elementos do vetor:
1 2 3 4 5 6 7 8 9 10