CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
201801 CSE240 Lecture 10
1. CSE240 – Introduction to
Programming Languages
Lecture 10:
Programming with C | Data Structures
Javier Gonzalez-Sanchez
javiergs@asu.edu
javiergs.engineering.asu.edu
Office Hours: By appointment
5. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5
Part 2
void push(struct node * head, int val) {
struct node * current = head;
while (current->next != NULL) {
current = current->next;
}
current->next = malloc(sizeof(struct node ));
current->next->val = val;
current->next->next = NULL;
}
6. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 6
Part 3
int pop(struct node ** head) {
int retval = -1;
struct node * next_node = NULL;
if (*head == NULL) {
return -1;
}
next_node = (*head)->next;
retval = (*head)->val;
free(*head);
*head = next_node;
return retval;
}
7. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 7
Part 4
void print_list(struct node * head) {
struct node * current = head;
while (current != NULL) {
printf("%dn", current->val);
current = current->next;
}
}
8. CSE240 – Introduction to Programming Languages
Javier Gonzalez-Sanchez
javiergs@asu.edu
Fall 2017
Disclaimer. These slides can only be used as study material for the class CSE240 at ASU. They cannot be distributed or used for another purpose.