Q:

Program crashes while creating list in C

I am creating a simple single link list. In function listIn(), until malloc() everything works just fine, but just after malloc() is executed my program crashes. I am not able to understand why?
It gives output like:

Process exited after 3.055 seconds with return value 3221225477
Press any key to continue . . .
Code:
main.c
//main 
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
#include"structure.h"
#include"List.h"

int main ()
{
    listIn(1);
    displ();
}
//end of main function.

List.h
//custom header file List.h (begin)

List *lstart = NULL;
void listIn(int hcode);
size_t listIsEmpty();
void dispList();

//function definition queueIn() to insert element into queue.

void listIn(int hcode)
{
    tmplist = (List *) malloc (sizeof ( List ) );
    if (tmplist = NULL)
    {
        puts("Memory Not available");
        return;
    }
    tmplist->lcode = hcode;
    tmplist->llink = lstart;
    lstart = tmplist;   
}

//end of function queueIn()

//function declaration displ() used to print queue

void displ()
{
    if( listIsEmpty() )
    {
        puts("List is Empty");
    }
    else
    {
        List *ptr;
        ptr = lstart;
        while(ptr != NULL)
        {
            printf("%d\n", ptr->lcode);
            ptr = ptr->llink; 
        }
    }
}

// function displ() end

// function declaration listIsEmpty() to check the status of queue.

size_t listIsEmpty()
{
    if(lstart == NULL)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

// custom header file List.h(end)

structure.h
//custom header file structure.h(begin)
// definition of all the structures
#include<stdbool.h>//for boolean data type.
#ifndef STRUCTURE_H_
#define STRUCTURE_H_
#include<stdbool.h>

typedef struct lnode
{
    int lcode;
    struct lnode *llink; 
}List;
List *tmplist;
#endif

// custom header file structure.h(end)

A:

The problem is here
if (tmplist = NULL)

This sets tmplist to NULL immediately after allocation. This fails the if test so the block isn't entered. The next line after the if crashes immediately.
Should read
if (tmplist == NULL)

You should be getting warnings about this. Always compile with warnings turned on.

