Friday, July 21, 2017

arrLength

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

int arrLength(list_t* list)
{
  if(list->head == NULL) return 0;

  element_t* el = list->head;
  int num = 1;
  while(el->next != NULL){
    num++;
    el = el->next;
  }
  return num;
}

/*void list_sort(list_t* list)
{
  pivot =
}*/

int main()
{
  list_t* list = list_create();

  for( int i=0; i<5; i++ ){
    list_append( list, i );
    if(list->tail->next != NULL) return 1;
  }
  printf("%d",arrLength(list));
}

No comments:

Post a Comment