My assigning still is not working properly, allow me to post some more code;
Code:
const int size=1000000;
struct node
{
int count;
string w;
} table [size];
Right here I want to create an array of 1000000 nodes called table.
Code:
do
{
word="";
do
{
c=fgetc(fp);
if (c >='a' && c<='z')
c=c-32;
ch=char(c);
word+=ch;
} while ((c>='A' && c<='Z') || c==39);
hash=hashfunction(word);
if (table[hash].w == "")
{
table[hash].w=word;
table[hash].count=1;
}
if (table[hash].w==word)
{
table[hash].count+=1;
}
} while (c!=EOF);
This segment of code is supposed to read in characters from a file pointer and first convert them to upper case, if applicable. Then pass the upper case string through a hash function which returns an int (the location of the struct in the array), and then assign that upper case word to string variable inside my struct. Just a basic word counter program here.