Tuesday, April 16, 2013

WAP to Illustrate use of Malloc Function


#include<stdio.h>
#include<conio.h>

void main()
{
int n,i,*p,
clrscr;


printf("Enter Number \n");
scanf("%d",&n);

p=(int*)malloc(n*sizeof(int));

for(i=0;i<n;i++)
{
scanf("%d",p);
p++;
}

p=p-n;

for(i=0;i<n;i++)
{
printf("\n%d",*p);
p++;
}

getch();

}

No comments:

Post a Comment