Program to use realloc() and free() functions


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

main()
{
char buf[80], *message;
printf("\nWhen create pointer it has no address and data also.");
printf("\nIn this program please enter at-least one line of text.");
printf(" Pfoof given below :\n");
message='\0';
printf("\nMessage is :%s",message);
printf("\nAddress is :%p",message);
printf("\n\nUsing reallocation function to update message pointer.");
printf("\nEnter line of texts :");
gets(buf);
message = realloc('\0', strlen(buf)+1);  //here 0 is previous data (NULL)
strcpy(message, buf);
printf("\nYou message is :%s",message);
printf("\nAddress is :%p",message);
char *x,*p;
x=&message;
p=free(x);
printf("\nMemory address is :%p",p);
getch();
}

Comments

Popular posts from this blog

Customize User's Profile in ASP.NET Identity System

Migrating database from ASP.NET Identity to ASP.NET Core Identity