-4

Unexpected error is occuring, Kindly help to resolve

/*Program to delete the nth Node from the Linked List*/

see the code piece here:

http://pastebin.com/esgv41aC

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
aruns
  • 1,049
  • 1
  • 8
  • 19
  • 1
    Hello ! Please add your code in stackoverflow not via pastbin. Thanks. – V. Couvignou Aug 18 '15 at 12:43
  • 2
    `void Insert(int data, int n); //insert the data in the list at given position n; {` remove `;`, `Print` ditto. – BLUEPIXY Aug 18 '15 at 12:46
  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a [mcve]. – too honest for this site Aug 18 '15 at 12:49
  • 1
    That is no C (using `new`). – too honest for this site Aug 18 '15 at 12:52
  • When I try to post in code section, only 1 line is getting posted, I am not able to fix it or understand why its happening, Thats why i used pastebin, Can't copy paste my code in one whole go. Any leads to learn? – aruns Aug 20 '15 at 17:39

1 Answers1

1

You forgot to add the name of the struct here:

struct{
    int data;
    struct Node* next;
};

It should be

struct Node {
    int data;
    struct Node* next;
};

Another problem is that you use new which is a C++ operator to allocate memory. In C, use malloc or calloc to allocate memory. Don't forget to check is return value to check if was successful in allocating memory.

Also, here

if (temp1 ==1)

You compare a pointer with an int. This is wrong. I don't know what you are trying to do here...

Spikatrix
  • 20,225
  • 7
  • 37
  • 83