Esta es la forma en que quiero:
#include <stdio.h>
#define SIZE 5
int main(){
int *lista;
int i;
lista
= (int*)(malloc(sizeof(int)*6)); *lista = (int)NULL;
for(i = 0; i < SIZE ; i++){
*lista++;
printf("Ingrese elemento N %d\n",i
); }
/*free(lista);*/
return 0;
}
Pero:
El compilador lanza el siguiente warning(gcc):
gcc v.c
v.c: In function ‘main’:
v.c:8: warning: incompatible implicit declaration of built-in function ‘malloc’
Y luego si compilo el código con free, al final tengo un error de segmentación, a qué se debe?
./a.out
Ingrese elemento N 0
1
Ingrese elemento N 1
2
Ingrese elemento N 2
3
Ingrese elemento N 3
4
Ingrese elemento N 4
5
Fallo de segmentación