I have this little code of a dynamic array exercise, it introduces me up to 6 elements and it displays them correctly, but if I put it from 8, it jumps an error "the program stopped working"
Code:
int main()
{
int cantidad;
int *x;
printf("Cantidad de valores del array: ");
scanf("%d",&cantidad);
x = (int*)malloc(sizeof(int));
for(int i=0;i<cantidad;i++)
{
printf("Numero: ");
scanf("%d",&x[i]);
}
//Visualizar Datos
for(int i=0;i<cantidad;i++)
{
printf(" %d",x[i]);
}
return 0;
}