> I want to verify whether the dynamic memory is allocated for three integer by malloc and it store value at allocated location
Well if malloc returns a non-null pointer, then you have your memory.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int asize = 3;
int *ptr = malloc(asize * sizeof(*ptr));
if (ptr != NULL) { /*Check for failure. */
int *temp = ptr;
int base = 10;
for (int i = 0; i < asize; i++) {
base += i * 3;
printf("Storing the value %d at memory location %p\n", base, (void *)temp);
*temp++ = base;
}
temp = ptr;
for (int i = 0; i < asize; i++) {
printf("the value at memory location %p is %d\n", (void *)temp, *temp);
temp++;
}
}
free(ptr);
return 0;
}