For an assignment, we have to use hashing to insert a dictionary(an array of linked lists) but I seem to be unable to set any of them to NULL.
btw: note this is my first C program, I learned to program entirely in Java prior to this.
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define WORDSIZE 32
#define TABLESIZE 2000
#define HASH_VALUE 13
int tablePosition;
struct LIST table[TABLESIZE]; //table
//global methods
int hash(char string[]);
struct NODE
{
char word[WORDSIZE];
struct NODE *next;
};
struct LIST
{
struct NODE listTop;
};
struct QUEUE
{
struct NODE queueTop;
struct NODE queueBottom;
}queue;
int main(int argc, char *argv[])
{
int i;
int arg;
char string[WORDSIZE];
FILE* word;
{
void insert();
}
arg=getopt(argc,argv,"d:");
if(-1!=arg)
word = fopen(optarg,"r");
else
printf("OOPS");
//sets the first character in each list to NULL to check for empty lists
for(i=0;i<TABLESIZE;i++)
table[i].listTop.word=NULL;
while(fgets(string,WORDSIZE,word))
{
printf("%s",string);
// insert(string);
}
fclose(word);
return EXIT_SUCCESS;
}
Code tags added by Hammer