if *p points to elt
what about the structure of the list
*p was pointing some other place
it should ruin the whole structure
whats happening?
i debugged this code
and i cant see whats happening in the end
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int value;
struct node *next;
}Node;
void what1(Node ** p,int num);
int main()
{
Node *p;
p=(Node *)malloc(sizeof(Node));
p->value=1;
p->next=(Node *)malloc(sizeof(Node));
p->next->value=2;
what1(&p,0);
free(p);
return 0;
}
void what1(Node ** p,int num)
{
Node *elt;
elt=(Node*)malloc(sizeof(Node));
elt->next=*p;
elt->value=num;
*p=elt;
}