Skip to content

Instantly share code, notes, and snippets.

@werbet
Created February 17, 2016 21:59
Show Gist options
  • Save werbet/845666064b252822310f to your computer and use it in GitHub Desktop.
Save werbet/845666064b252822310f to your computer and use it in GitHub Desktop.
Alocação de memória
#include <stdio.h>
#include <stdlib.h>
int main()
{
int quantidade;
int* p;
int i;
int j;
printf("Digite a quantidade de meias: \n");
scanf("%d", &quantidade);
printf("quantidade = %d \n", quantidade);
p = malloc(quantidade * sizeof(int));
for(i = 0; i < quantidade; i++)
p[i] = i;
for(j = 0; j < quantidade; j++)
printf("p[%d] = %d \n", j, p[j]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment