I have a simple question about this code

struct a
{
    char key;
    a *next;
};
a = here*;

and in the function I check if here is NULL or not

if (here->key==NULL)
...

and Im sure here is pointing to an a(struct) but it gives access violation . what should I do to check if something Is NULL or not ?

a = here*;

This isn't valid syntax.

and in the function I check if here is NULL or not

You're not checking if here is NULL, you're checking if here->key is NULL. here->key is a char, so the test is nonsensical given that one of the operands is not a pointer. If here is NULL then trying to access key will result in an access violation. You want to do this:

if (here == NULL)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.