Skip to main content
Logo image

Section 27.7 Append Digits to List

Now that we can create new digits in memory, the next step is to be able to link digits together into a number (= a linked list of digits). We’ll take an iterative approach in which we simply keep adding on digits to the current end of our list of numbers.

Activity 27.4.

Please write the function append() which takes two digit_t pointers as arguments:
  • a pointer to the current last element of the list
  • a pointer to the element that is to be appended to the list
Since by appending a new digit the end of the list will change, the function needs to return a pointer to the new last element of the list. Please also print the (three-digit) number stored in the newly created list and next free the space reserved for all digits.

admin.....open in new window

When you are done, please paste your code into the code submission box below: