no compile errors but not working properly

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*/

#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include <iomanip.h>
#include <stdlib.h>
using namespace std;




class WordCount
{
public:
char word[31];
int count;

};


typedef WordCount WordEntryList;

void cleanupbegin (char word[31]);
void cleanupend (char word[31]);
int avgLetter(int count,int z, char word[31]);
void store(char word[31],int& count, WordEntryList[]);
void tagbyletter ( int count, int tag[], WordEntryList[]);
void tagbynumber ( int count, int tag[], WordEntryList[]);

int main ()
{

int e;
int typo;
int i;
int z;
int avgoccur;
int numWords;
int tag[5000];

char n;
char filename[41];
char wordFromFile[31];
char word[31];
char choice;


typo=1;
numWords=0;
i=0;
z=0;

ifstream inFile;

WordEntryList myList[500];

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;

cout<< " "<<myList[tag[e]].count<<endl;
avgoccur=((myList[e].count)/numWords*100);
cout<<"avg"<<avgoccur<<endl<<endl;
}



system("PAUSE");
inFile.close();
return 0;

}







//==========================================================================

void cleanupbegin (char word[]) // cleans up the left side of the word

{
int n;
char x[31];
n=0;

if (( word[n] < 'A' || word[n]>'Z') && (word[n] < 'a' || word[n] > 'z'))
{

while(word[n]!='\0')
{
word[n]=word[n+1];
n++;
}
}
else;



return;

}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

void cleanupend (char word[]) // cleans up the right side of the word
{
int done;
int y;
int len;



done = 0;

y = strlen(word);

while (!done)
{
if (( word[y] <'A' || word[y] > 'Z') && ( word[y] <'a' || word[y] >'z'))
{
word[y] = '\0';
y--;
}
else
done = 1;
}

len=strlen(word);
if(word[len-1]=='s')
{
if(word[len-3]=='i'&&word[len-2]=='e')
{
word[len-3]='y';
word[len-2]='\0';
}
if(word[len-2]=='e')
word[len-2]='\0';
if(word[len-2]==39)
word[len-2]='\0';
else
word[len-1]='\0';
}






return;
}



//==============================================================================

void store(char word[],int& numWords, WordEntryList myList[]) // I added a name for the variable WordEntryList
{
int found;
int n;
found=0;
n=0;


while (n<numWords && !found)
{
if (strcmp(myList[n].word,word)==0)
found=1;
else;
n++;
}
if (found)
{myList[n].count++;
numWords++;
cout<<"got here";}
else
{
strcpy(myList[numWords].word,word);
myList[numWords].count=1;
numWords++;
}
return;
}

//=============================================================================

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++;
}

return z;
}
Topic archived. No new replies allowed.