Demonstration of a singly linked list This is a simple demonstration of a singly linked list, from my class work:

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;wctype.h&gt;
#include &lt;errno.h&gt;
#include &lt;assert.h&gt;
#include &lt;ctype.h&gt;
#include &lt;stddef.h&gt;
#include &lt;wchar.h&gt;
#include &lt;locale.h&gt;
#include &lt;setjmp.h&gt;
struct node
{
    int          info;
    struct node *link;
};

typedef struct node* NODE;

NODE main()
{
    NODE first = NULL;
    int  item, choice;

    for(;;)
    {
        printf("1.INSERT AT FRONT\n2.DISPLAY\n3.QUIT\n\nPLEASE ENTER YOUR CHOICE:");
        scanf("%d",&amp;choice);

        switch (choice)
        {
            case 1:
            printf("\nEnter the item to be inserted:");
            scanf("%d", &amp;item);

            first = insert_front(item,first);
            break;

            case 2:
            display(first);
            break;

            case 3:
            exit(0);
        }
    }
}

NODE getnode()
{
    NODE x;

    x = (NODE) malloc(sizeof(struct node));
    if(x == NULL)
    {
        printf("Out of memory");
        exit(0);
    }
    return x;
}

int insert_front(int item, NODE first)
{
    NODE temp;
    temp = getnode();
    temp-&gt;info = item;
    temp-&gt;link = first;
    return temp;
}

void display(NODE first)
{
    NODE temp;

    if(first == NULL)
    {
        printf("Empty");
        return;
    }

    printf("\nThe contents are: ");

    temp = first;
    while(temp != NULL)
    {
        printf("%d ", temp-&gt;info);
        temp = temp-&gt;link;
    }
    printf("\n");
}


As you can see, this code demonstrates the working of a linked list. How can this program more smaller, better, more professional and much more good? If you were given a chance to modify this program, how would you do it? I wanna know how to think and how to train myself to modify programs like these. And as you see, I have learned most of C. I referred to and learned C from K.N Kings The C programming language: A modern approach and Computer science: A structured approach using C and data structures from Data structures using C by Tenenbaum.

Now I have stretched my legs in learning C what can I do to create application that might be useful to me or to others. Say I want to create a small game like "snake" or create a small application that my father might use to do his business.
I'm not a C-guru at all but I believe I can give you a few advices to improve your code:


Review your included libraries. Do you really need all those ones? Nope. Chuck Testa You only use stdio.h and stdlib.h.
main() should return int and you specify it actually returns NODE... but it isn't returning nothing at all! Double fail x( So... int main() { return 0; } FTW
Naming consistency. You have written getnode() and insert_front(). You can name your members whatever you want (getnode(), getNode(), get_node()) but keep the patter for all of them (insertfront(), insertFront(), insert_front()). IMO, underscores are much C-style.
Blank lines. Avoid inserting blank lines. They don't clarify the reading of your code, instead of that they expand your code unnecessarily. You can insert blank lines between your function definitions. This helps to delimit and group your functions and eases their location.
What if I type 4 in your menu? The golden rule in programming is: Users provide bad inputs. So you always must to validate inputs. Don't matter if it seems trivial. Always.
And for last and getting a bit cranky, you can get a temp node in one step within insert_front():

NODE temp = get_node(); // I've changed `getnode()` name for you. You are welcome.