UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2015 - January 2016

Programming with linked lists

Lab activities

1.  Creating a linked lists

Resources

  • Program implementing a menu with various options and the functions struct node *create_node(struct ap_scan_info *cell) and void print_node(struct node *node_ptr) already implemented.

  • Folder with name List_aps in your shared folder in Subversion. Local copy available here.

  • To self-checking your code, you can use: test_menu_operations_dynnamic_list_en.sh

Work Plan

Using the program of the option menu with the previously mentioned functions, make the following modifications:

  1. Implement the function struct node *create_list(struct ap_scan_info *array, int size) that receives as input parameters an array of data structures struct ap_scan_info and returns a linked list. In order to obtain this, use the previously defined data type and the function struct node *create_node(struct ap_scan_info *cell) (from the previous activities).

  2. Add and implement a new menu option to create a linked list from the array. Store this list in a variable so that it can be used in other options.

  3. Add and implement a new menu option to show all the access points in the linked list. Use the function void print_node(struct node *node_ptr) from the previous activities.

  4. Add the required code so that the list, if it exists, is destroyed when the program terminates.

Optionally, upload the file to the repository with svn commit.

How long did this activity take you? mins.

2.  Activities after the session (optional)

An additional exercise is included next to practice more linked list operations.

Deleting nodes of a linked list

Resources

  • Program implementing a menu with various options and including the function struct node *create_list(struct ap_scan_info *array, int size) and the code to destroy the list when the program terminates.

  • Folder with name List_aps in your shared folder in Subversion. Local copy available here

Work Plan

Using the program of the option menu make the following modifications:

  1. Implement the function struct node *delete_essid_in_list(struct node *, char *essid) that receives a linked list and a string containing a essid and deletes every single node in the list whose essid is the given. The function returns the modified list.

  2. Add and implement a new menu option to delete a essid from the a linked list. Use the function getline

Optionally, upload the file to the repository with svn commit.

How long did this activity take you? mins.