1. Define a structure called entry that has at least three elds: a pointer to char (which will be used as a string), an integer counter, and a pointer to another entry structure. Write a function called new entry that accepts a string as an argument, then allocates a new entry structure and initializes it with a copy of the string passed to it. For this you will need to allocate space both for the structure and for the copy of the string that it is to point to (using two separate calls to malloc). Initialize the other elds too, as appropriate, and return a pointer to the new entry structure as the function value. Note: the function new entry should place no limit on the size of the string it can hold, since it is to allocate as much space as it needs to hold the string passed to it.

2. Write a function called add to dictionary that accepts a single string argument (i.e. pointer to char), and does one of two things with that string. If the string has already been added to the \dictionary", then it will simply increment the counter associated with that word. Otherwise, it will add the string to the dictionary. Ordering is unimportant here, so you can add the a new entry structure at the beginning or at the end of the existing list. Either way, you will need to maintain a global variable that points to the rst entry of the dictionary.

3. Write a function called make dictionary that accepts a single string argument, which it assumes is the name of a text file to open. It should open the le using fopen and read one character at a time using getc until it returns EOF (end of file). The function make dictionary should look for sequences of alphabetic characters delimited by spaces, punctuation marks, newlines,



This is what i have for part 1 and 2....need help with part 3


Code:
#include <stdio.h> //calling library
#include <math.h> //calling library
#include <stdlib.h>
#include <string.h>

struct entry 
{
	char *word;
	int counter;
	struct entry *next_entry;
} *dictionary, *first; 

entry* new_entry(char*s)
{ 
	struct entry *x = NULL;
	x = (entry*) malloc(sizeof(entry)); 
	x->word=(char*)malloc(strlen(s)); 
	x->counter=0;
	strcpy(x->word,s);
	x->next_entry = NULL;
	return x;
}

void add_to_dictionary( char *word )
{
  struct entry *temp;
  struct entry *newEntry;
  
  // Look for a match for "word"
  for(temp = first; temp != NULL; temp = temp->next_entry)
  {
    if(strcmp(temp->word, word) == 0)
    {
      // Increment the counter
      temp->counter++;

      // No reason to go on
      return;
    }
  }

  // If we got here, we did not find a match so add one
  newEntry = new_entry(word);
  
  // this is the first entry
  if(first == NULL)
  {
    first = newEntry;
  }
  else
  {
    // Find the last entry
    temp = first;
    while(temp->next_entry != NULL) 
    {
      temp = temp->next_entry;
    }
    temp->next_entry = newEntry;
  }  
}

void make dictionary( char *fname )
{ //what should i put here?}

int main()
{

}



So i managed to to get help and finish part 1 and 2, however i am not sure how to start part 3.... can some one help me out with this?