creating an ADT using its function - C
So, I'm trying to write a function which return a pointer to an ADT, in the heep.
the problem is that I can't manipulate it after the memory allocation. here is a simplified code

    typedef struct _entity {
            int value;
            } *Entity;
            

    Entity *new_entity(){
    Entity *ptr = (Entity*)malloc(sizeof(struct _entity));
    assert( ptr );

    (*ptr)->value = 5; // program crashes after this line

    return ptr;
    }

 
the error is:
Unhandled exception at 0x013e1665 in test.exe: 0xC0000005: Access violation writing location 0xcdcdce21.
creating an ADT using its function - C
===

So, I'm trying to write a function which return a pointer to an ADT, in the heep.
the problem is that I can't manipulate it after the memory allocation. here is a simplified code

    typedef struct _entity {
            int value;
            } *Entity;
            

    Entity *new_entity(){
    Entity *ptr = (Entity*)malloc(sizeof(struct _entity));
    assert( ptr );

    (*ptr)->value = 5; // program crashes after this line

    return ptr;
    }

 
the error is:
Unhandled exception at 0x013e1665 in test.exe: 0xC0000005: Access violation writing location 0xcdcdce21.