Implementing a Spell Checker

This is a discussion on Implementing a Spell Checker within the C Programming forums, part of the General Programming Boards category; Hello everybody: I have to implement a spell checker for my school assignment. This means reading in a dictionary file ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    5

    Post Implementing a Spell Checker

    Hello everybody:

    I have to implement a spell checker for my school assignment. This means reading in a dictionary file into a hash table with chaining. I have a general linked list ADT that I will use for the chains. The following structure will define the HashTable:

    Code:
    typedef struct hashtable{
    int tablesize; 
    List *table;
    }HashTable;
    Here, tablesize will represent the size of the table which we do not know before hand, but will be calculated to be a percentage of the size of the number of words in the dictionary.

    I believe the following can be used to initialize an empty HashTable:
    Code:
    void CreateTable(HashTable *H)
     {
           int i;
           int tablesize = H->tablesize;
       
           H->table = (List *)malloc(tablesize*sizeof(List *));
           for(i=0; i<tablesize; i++)
            CreateList(H->table+i);
    }
    Here, CreateList is a function from the List ADT. I do believe that the the call to malloc allocates enough memory to hold an array of pointers to linked list; this array of pointers should be tablesize long (i.e. the size of the table). Also, would H->table+i or H->table++ increment along this array of pointers.

    Thanks,
    tim

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    If you have a pointer, and you pass it to a function, the function can only change the value what that pointer is pointing to. If you want to make the pointer itself point to something new inside the function, you have to pass a pointer to that pointer instead.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple spell checker
    By purplechirin in forum C Programming
    Replies: 31
    Last Post: 03-19-2008, 07:17 AM
  2. Spell Checker
    By DeepFyre in forum Tech Board
    Replies: 2
    Last Post: 02-11-2005, 11:17 AM
  3. Spell checker poem.
    By adrianxw in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-13-2004, 09:49 AM
  4. spell checker in c needs help
    By madmax in forum C Programming
    Replies: 3
    Last Post: 03-13-2003, 08:36 AM
  5. spell checker
    By bob20 in forum Windows Programming
    Replies: 3
    Last Post: 12-03-2002, 01:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21