Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct ListNode{
- int value;
- struct ListNode* next;
- };
- void appendNode(struct ListNode* head, int num){
- struct ListNode* nodePtr;
- struct ListNode* newNode;
- newNode = malloc(sizeof(struct ListNode));
- newNode->value = num;
- newNode->next = NULL;
- if(!head)
- head = newNode;
- else{
- nodePtr = head;
- while(nodePtr->next)
- nodePtr = nodePtr->next;
- nodePtr->next = newNode;
- }
- }
- int main(){
- struct ListNode* head;
- head = NULL;
- appendNode(head, 5);
- printf("%p", head);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement