I saw the forum and thought maybe i could get some help. I'm kind of new to programming and I've been taking a few classes on it and I've got this program I've been putting together for class and it will complile with no errors but for some reason it's not adding the count up or atleast if it is it's not showing it at run time. any help or suggestions would be appreciated.
/*this program will take an input file
and make a list of the words in that file
and if there is multiple uses of that word
the word it will be counted*/
cout<< "Input file for word count:"<<endl;
cin>>filename;
inFile.open(filename);
if( inFile.fail() )
{
cout<< "Error could not use this file";
system("PAUSE");
exit(1);
}
else;
while (inFile.peek() != EOF)
{
inFile>>word;
cleanupbegin(word); //gets rid of punctuation
cleanupend(word); //gets rid of punctuation
avgLetter (numWords, z, word);
store( word, numWords, myList); //store word returns numWords
}
cout<<"The number of words in your list is:"<<numWords;
cout<<"The average size of the word is:"<<z;
cout<<" letters long"<<endl<<endl;
tagbynumber(numWords,tag,myList);
cout<<"The top 10 words that occurred most often are:"<<endl;
for (e=0;e<100&& e<numWords; e++)
{
cout<< myList[e].word;
void tagbyletter (int numWords, int tag[], WordEntryList myList[])
{
int n;
int p;
int q;
int o;
int tmp;
for (n=0; n<numWords-1; n++)
tag[n]=n;
for(p=0;p<numWords-1;p++)
{
for (q=p+1; q<numWords;q++)
if( stricmp(myList[tag[p]].word, myList[tag[q]].word)>0)
{
tmp=tag[p];
tag[p]=tag[q];
tag[q]=tmp;
}
else;
}
return;
}
//===============================================================================
void tagbynumber ( int numWords, int tag[], WordEntryList myList[])
{
int n;
int p;
int q;
int tmp;
for (n=0; n<numWords; n++)
tag[n]=n;
for (p=0; p<(numWords-1); p++)
{for (q=p+1; q<numWords;q++)
if (myList[tag[p]].count < myList[tag[q]].count)
{
tmp=tag[p];
tag[p]=tag[q];
tag[q]=tmp;
}
else;
}
return;
}
//=============================================================================
int avgLetter(int numWords, int z, char word[31])
{
int w;
int y;
int done;
for (w=0; !done;w++)
{
y=0;
done=0;
if (word[w] =='\0')
{
z=y+z;
done=1;
}
else
y++;
}