#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef struct Node
{
int data;
struct Node* next;
}NODE,*LIST,*LPNODE;
LPNODE createNode(int data)
{
LPNODE newNode = (LPNODE)malloc(sizeof(NODE));
assert(newNode);
newNode->data = data;
newNode->next = NULL;
return newNode;
}
void insertHead(struct Node** list,int data)
{
LPNODE newNode = createNode(data);
newNode->next = *list;
*list = newNode;
}
void printList(LIST list)
{
LPNODE pMove = list;
while (pMove != NULL)
{
printf("%d\t", pMove->data);
pMove = pMove->next;
}
printf("\n");
}
void modify(int a)
{
a = 100;
}
void modifyPoint(int* a)
{
*a = 100;
}
int main()
{
LIST list = createNode(100);
for (int i = 0; i < 3; i++)
{
insertHead(&list, i);
}
printList(list);
LIST result = createNode(list->data);
LPNODE pmove = list->next;
while (pmove != NULL)
{
insertHead(&result, pmove->data);
pmove = pmove->next;
}
printList(result);
int num = 1;
modify(num);
printf("%d\n", num);
modifyPoint(&num);
printf("%d\n", num);
return 0;
}