Esempio n. 1
0
int main(int argc,char *argv[])
{

  //this makes the head of the list
  //it starts off as a null pointer but gets
  //updated when the first piece of data is added.

  list *linked_list;
  linked_list=NULL;

  book=fopen(argv[1],"r");
  clock_t start=clock();
  linked_list=insertwordlist(linked_list);
  clock_t stop=clock();
  fclose(book);

  double time_taken=(stop-start)/CLOCKS_PER_SEC;

  printf("%f\n",time_taken);

  printf("%i\n",find(linked_list,"cow"));
  printf("%i\n",find(linked_list,"computer"));

  int step;
  list *location;
  location=find_word(linked_list,"moocow",&step);
  int this_count=location->count;
  printf("%i\n",this_count);

  return 0;
}	
Esempio n. 2
0
//This function adds words to the linked list and also times the time it takes to finish adding the words. Prints the time taken.
list *createLinkedList(FILE *book, list *linked_list, char *argv[]) {
    book = fopen(argv[1], "r");
    clock_t start = clock();
    linked_list = insertwordlist(book, linked_list);
    clock_t stop = clock();
    double time_taken = (stop - start) / (double) CLOCKS_PER_SEC;
    printf("Time taken for linked list: %f\n", time_taken);
    fclose(book);
    return linked_list; 
}