getting runtime error in C

Problem statement: http://www.spoj.com/LAB8E/problems/DATAD/

My code link: http://ideone.com/eyzOtZ
I am using linked list.
I am getting runtime error . So please help me.

You are using new as a variable which is a reserved keyword in C++. The compiler Ideone is using is not strictly made to ignore C++ keywords. To avoid conflicts, change it.

Edit: Also, You have written last->next=new but at this point last is not pointing to any structure. It is a dangling pointer. Therefore the runtime error

I am using gcc compiler(4.3.2 version ,i think).
Still getting runtime error.

Definitely, try changing the new keyword to like new_node or something

And when I write code in Code Blocks with GCC, it recognizes the C++ keywords too.Just open an editor and use REPLACE function to replace all “new” with “something”

i replaced new with ne. But still getting runtime error. Please help me.

See the changed answer