i have written one small c programme for dynamic memory allocation.But when programme runs memory is not getting allocated. So its output is only "error".So what could be the problem?
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
int *array;
clrscr();
array=(int*)malloc(sizeof(int));
if(array==NULL);
{
printf("error");
return;
}
*array=6;
printf("%d",*array);
free(array);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
int *array;
clrscr();
array=(int*)malloc(sizeof(int));
if(array==NULL);
{
printf("error");
return;
}
*array=6;
printf("%d",*array);
free(array);
getch();
}