Showing posts with label Array Using Realloc In C. Show all posts
Showing posts with label Array Using Realloc In C. Show all posts

Monday, 29 October 2012

Program Of GET PUT Function In C

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
 
main()
 
{
 
clrscr();
 
int i,a,m,n;
 
printf("Enter No. Of Char");
 
scanf("%d",&m);
 
printf("\n Contens Of Main File=");
 
for(i=1;i<=m;i++)
 
{
 
scanf("%d",&n);
 
if(n==-1)
 
break;
 
}
 
fclose(f1);
 
f1=fopen("Main","r");
 
f2=fopen("ODD","w");
 
f3=fopen("EVEN","w");
 
while(a!=EOF)
 
{
 
if(a%2==0)
 
{
 
}
 
else
 
{
putw(a,f2);
 
}
 
a=getw(f1);
 

fclose(f1);
 
fclose(f2);
 
fclose(f3);
 
f2=fopen("ODD","r");
 
f3=fopen("EVEN","r");
 
printf("Content of ODD File \n");
 

{
 
printf("%d\n",a);
 
}
 
printf("Content Of Even File\n ");
 
while(a=getw(f3)!=EOF)
 
{
 
printf("%d\n",a);
 
}
 
fclose(f2);
 
fclose(f3);
 
getch();
 
}

Thursday, 18 October 2012

Program Of Array Using Realloc In C

#include<stdio.h>
#include<conio.h>
 
main()
 
{
 
int *a,i,n,y;
 
clrscr();
 
printf("How many Blocks U want to Create For Array =");
 
scanf("%d",&n);
 
for(i=0;i<n;i++)
{
 
}
 
for(i=0;i<n;i++)
 
{
 
printf("a[%d]==> ",i);
 
scanf("%d",&a[i]);
 
}
 
printf("\n============Array Is=============\n");
 
for(i=0;i<n;i++)
 
{
 
printf("\n a[%d]==>%d ",i,a[i]);
 
}
 
printf("\n How Many Memory U want to Reallocate =");
 
scanf("%d",&y);


for(i=0;i<y;i++)
{
 
}
 
for(i=n;i<n+y;i++)
 
{
 
printf("a[%d]==> ",i);
 
scanf("%d",&a[i]);
 
}
 
printf("\n======== again Array Is=============\n");
 
for(i=0;i<n+y;i++)
 
{
 
printf("\n a[%d]==>%d ",i,a[i]);
 
}
 
getch();
 
}

-------------------------------------------------------------------------------

What is Realloc ?


The Realloc() function changes the size of a block of memory that was previously allocated with Malloc() or Calloc().