Skip to content

Instantly share code, notes, and snippets.

@febuiles
Forked from anonymous/gist:132013
Created June 18, 2009 17:20
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 febuiles/132030 to your computer and use it in GitHub Desktop.
Save febuiles/132030 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
main(){
int i;
int *arreglo;
arreglo = (int *)malloc(sizeof(int));
for(i = 0; i < 10; i++){
arreglo = realloc(arreglo, (i + 1) * sizeof(int)); /* importante que sea i + 1 pa no
multiplicar por cero */
arreglo[i] = i;
}
for(i = 0;i < 10; i++)
printf("%d\n",arreglo[i]);
free(arreglo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment