I just got my test back and I was only able to spot 2 and our prof doesnt give us correct answers upon return.. wondering if you guys can help me spot 4 errors in this code for a linked list…
int main() {
struct node
{
int data;
node * next;
}
// create empty list
node * list;
// insert six nodes at front of list
node *n;
for (int i=0;i<=5;i++)
{
n = new node;
n->data = i;
n->next = list;
}
// print list
n = list;
while (!n)
{
cout << n->data << " ";
n = n->next;
}
cout << endl;
struct nodemissing;at the end of it’s declarationlistnot initialized toNULLlistisn’t pointing to the head after nodes insertionwhile(n)instead ofwhile(!n)