Make a program to allocate space in memory for 10 integers and ask the user to enter 10 values. Then print out their memory address and content.
What do I have to change in my program so that it works?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, *p;
p = (int*)malloc(10*sizeof(int));
if (!p);
{
printf("Nao foi possivel alocar o vetor !");
exit(0);
}
for(i=0; i<10; i++)
{
printf("Digite um valor: ");
scanf("%d", &p[i]);
}
for(i=0; i<10; i++)
{
printf("Endereço de memoria: %d\nConteudo: %d\n", &p[i], p[i]);
}
free(p);
return 0;
}