Raghav Solutions

Raghav Solutions

Share

Raghav Solutions provides Training in Various programming languages like C,C++,Visual studio.Net, PHP for B.E.,B.C.A. M.C.A. and other technical students.

24/04/2020

//Realloc Example



int main()
{
int *ptr, i , n1, n2;
printf("Enter size: ");
scanf("%d", &n1);

ptr = (int*) malloc(n1 * sizeof(int));

printf("Addresses of previously allocated memory: ");
for(i = 0; i < n1; ++i)
printf("%u\n",ptr + i);
printf("\nEnter the new size: ");
scanf("%d", &n2);
// rellocating the memory
ptr = realloc(ptr, n2 * sizeof(int));
printf("Addresses of newly allocated memory: ");
for(i = 0; i < n2; ++i)
printf("%u\n", ptr + i);

free(ptr);

return 0;
}

Photos from Raghav Solutions's post 24/04/2020

Dynamic Memory Allocation Functions(Continued...)

Want your school to be the top-listed School/college in Khargone?
Click here to claim your Sponsored Listing.

Telephone

Website

Address


Khargone
451001

Opening Hours

Monday 5pm - 9pm
Tuesday 5pm - 9pm
Wednesday 5pm - 9pm
Thursday 5pm - 9pm
Friday 5pm - 9pm
Saturday 5pm - 9pm