I am using CODEBLOCKS and I am creating a program that performs basic operations like add, delete and insert on Doubly LinkList , My Program is working fine on older Turboc compilers. But when i run it on codeblock its causing problem when i try to delete a node.

typedef struct dnode
 {
      struct dnode *prev;
      char name[20];
      struct dnode *next;
 }DNODE;

DNODE *p;

Function that causes Problem is:

char * del_node(int loc)
{
    DNODE *temp;
    char *n;
    int i;
    
    if( !p )
         return "\n    List is Empty!!";
    if(loc >= 1 && loc <= count())
    {
         temp = p;
         if(loc == 1)
	         p = temp->next;
         else
         {
	         for( i = 1 ; i < loc ; i++ , temp = temp->next );

	         temp->prev->next = temp->next;
         }

         if(temp->next != NULL )
	         temp->next->prev = temp->prev;

         strcpy( n ,temp->name);
         free(temp);
         return n;
    }
    else
        return "\n    Location not found!!";
}

After Addind some nodes when i tried to delete perticular node it's causing this Error:
DLL.exe has stopped working

Problem signature:
Problem Event Name: APPCRASH
Application Name: DLL.exe
Application Version: 0.0.0.0
Application Timestamp: 4d0a048c
Fault Module Name: msvcrt.dll
Fault Module Version: 7.0.6000.16386
Fault Module Timestamp: 4549bd61
Exception Code: c0000005
Exception Offset: 0001debe
OS Version: 6.0.6000.2.0.0.768.3
Locale ID: 1033
Additional Information 1: 95be
Additional Information 2: 0b3ac16632013f96d01bca0b26ef6e8a
Additional Information 3: ee18
Additional Information 4: e8f12fa66c3490bfb4e8923744a2b7b9


I Figured out that perticular line that's causing problem

strcpy( n ,temp->name);

if i remove strcpy() function then it's not showing any Error. I could'nt understand why strcpy() is terminating my program..

I am new to CODEBLOCKS , Recentely switched from older Compilers.

Well I got the solution now..

After allocating Memory for *n its working now..

n = (char *) malloc (20 * sizeof(char));

But I am still a bit confused why did it work on old Turboc compilers.

Plzz Clearfy!!

Thanks.