Ihave been trying to test my load function separately,since I have not implemented other functions,size,check,unload . I have got the following Clang error " expected identifier". I do not know how to eliminate this error.Any help in this regard will be appeciated. I have also another question. When we use a hash table, how do we ensure we check for collisions? Everytime that we calculate a new value using the hash function,do we check that value with all the earlier values calculated. I thought this would be very inefficient. Hence there must be a quicker way to detect collisions in the hash Table. uma1966
/**************************************************************************** * dictionary.c * * Computer Science 50 * Problem Set 5 * * Implements a dictionary's functionality. ***************************************************************************/
#include <stdbool.h>
#include "dictionary.h"
#include <stdio.h>
/**
* Returns true if word is in dictionary else false.
*/
bool check(const char* word)
{
int strcmp(const char *text, const char *dictionary);
return false;
}
/**
* Loads dictionary into memory. Returns true if successful else false.
*/
bool load(const char* dictionary);
// load dictionary
{FILE* fp = fopen(dictionary, "r");
if (fp == NULL)
{
printf("Couldn't open %s.\n", dictionary);
return false;
}
array key;
key=*dictionary;
int hash_function(char* key);
int size2;
key=atoi(key[0]);
int hash=key;
return hash%size2;
// mod by size to stay w/in bound of table
{
typedef struct node
{
char LENGTH;
char word[LENGTH+1];
struct node* next;
}
node;
typedef struct node
{
char word[LENGTH+1];
struct node* next;
}
node* hashtable[500];
new_node->next=head;
// malloac a node* for each new_word
node* new_node=malloc(size of node);
fscanf(file,"%s",new_node->word);
while (cursor!=NULL)
{
cursor=cursor->next;
}
return false;
}
/**
* Returns number of words in dictionary if loaded else 0 if not yet loaded.
*/
unsigned int size(void)
{
// TODO
return 0;
}
/**
* Unloads dictionary from memory. Returns true if successful else false.
*/
Clang error
clang -ggdb3 -O0 -Qunused-arguments -std=c99 -Wall -Werror -c -o dictionary.o dictionary.c dictionary.c:33:5: error: expected identifier or '(' {FILE* fp = fopen(dictionary, "r"); ^ 1 error generated. make: *** [dictionary.o] Error 1 jharvard@appliance (~/Dropbox/pset5):