struct node {
int data;
struct node *next;
};
VOID teststurct()
{
DBG_PRINT("测试用例teststurct******************\n");
struct node *head, first;
struct node *second = (struct node *)malloc(sizeof(struct node));
head = &first;
first.data = 1;
first.next = second;
int a=1,i;
for(i=0;i<10;i++)
{
second->data = a++;
second->next=(second+sizeof(struct node));
second+=sizeof(struct node);
// first=first.next
}
second-=sizeof(struct node);
second->next = NULL;
while (head) {
printf("%d\n", head->data);
head = head->next;
}
}
测试结果如下: