C linked list search function
    /*Create linked list */
    struct node {
       	int number;
    	int occurence;
    	struct node *next;
    };
    
    /*Call our linked list freqTable */
    struct node *freqTable = NULL;

So i have this. Im trying to create a search function.

I'm not sure what im doing wrong, but I'm not getting the correct reference to freqTable.

I have tried

    bool elementExists(int n){...}

as well as 

    bool elementExists(struct node *list, int n){...}

But even in

    bool elementExists(int n){...}

i try to test it like

    bool elementExists(int n){
    printf("%d", freqTable->number);
    return false;
    }

It returns as "Segmentation fault". Where if i pass it in then i get some weird numbers which tells me its pointing to the wrong memory address.

Also if i print it in main, then it works fine.

Any clue as to why this is happening?

Thanks.
C linked list search function
===

    /*Create linked list */
    struct node {
       	int number;
    	int occurence;
    	struct node *next;
    };
    
    /*Call our linked list freqTable */
    struct node *freqTable = NULL;

So i have this. Im trying to create a search function.

I'm not sure what im doing wrong, but I'm not getting the correct reference to freqTable.

I have tried

    bool elementExists(int n){...}

as well as 

    bool elementExists(struct node *list, int n){...}

But even in

    bool elementExists(int n){...}

i try to test it like

    bool elementExists(int n){
    printf("%d", freqTable->number);
    return false;
    }

It returns as "Segmentation fault". Where if i pass it in then i get some weird numbers which tells me its pointing to the wrong memory address.

Also if i print it in main, then it works fine.

Any clue as to why this is happening?

Thanks.