I am making a hashing program that is counting the number of each instance of a word in a text file. This is my count function: I am getting an error when trying to run it.
56 Expression: (unsigned)(c + 1) <= 256
It appears as though it is crashing on the isalpha function when it is reading in the very first nonalpha garbage characters in the text file.
int
count(ifstream & fs,int size)
{
int find(const char *,int, int);
int f,i,l,y;
char ch,*p,s[maxs+1];
for(y = l = i = 0; i < size; i++)
{
table[i].k = 0;
table[i].p = nill;
}
p = s;
while(fs.get(ch))
{
if(isalpha(ch))
{
if(l < maxs)
{
l++;
*p++ = (char)(ch | 0x20);
}
}
else
{
if(l)
{
*p = '';
if(f = find(s,size,l) < 0)
{
return(f);
}
y += f;
p = s;
l = 0;
}
}
}
}
See Question&Answers more detail:os