UNB/ CS/ David Bremner/ tags/ pointers

This feed contains pages with tag "pointers".

Fill in the three missing functions in this code, so that numbers are printed out in order. Note that you can debug print_numbers independently.

#include <stdio.h>
#include <stdlib.h>

struct node {
  int value;
  struct node *next;
};

struct node *read_numbers(void){
  struct node *first = NULL;
  int n;
  printf("Enter a series of integers" 
         " (0 to terminate): ");
  for (;;) {
    scanf("%d", &n);
    if (n == 0)
      return first;
    first = add_to_list(first, n);
  }
}

struct node *reverse(struct node *list){
}

struct node *add_to_list(struct node *list, n){
}

void print_numbers(struct node *list){
}

int main(void){
  struct node *list=NULL;

  list=read_numbers();
  list=reverse(list);
  printf("output: \n");
  print_numbers(list);
}
Posted Tue 24 Nov 2009 12:00:00 AM Tags: /tags/pointers
  • Chapter 16,17 Enumerations, Pointers

  • slides printable

  • about slides

Posted Fri 20 Nov 2009 12:00:00 AM Tags: /tags/pointers
Posted Wed 04 Nov 2009 12:00:00 AM Tags: /tags/pointers
Posted Mon 02 Nov 2009 12:00:00 AM Tags: /tags/pointers
Posted Fri 30 Oct 2009 12:00:00 AM Tags: /tags/pointers
  • Chapter 12. Pointers and Arrays, Chapter 13 Strings

  • slides printable

  • about slides

Posted Wed 28 Oct 2009 12:00:00 AM Tags: /tags/pointers
  • Chapter 12. Pointers and Arrays

  • slides printable

  • about slides

Posted Mon 26 Oct 2009 12:00:00 AM Tags: /tags/pointers
  • Chapter 11, Chapter 12. pointers

  • slides printable

  • about slides

Posted Fri 23 Oct 2009 12:00:00 AM Tags: /tags/pointers