i think the problem lies in the way i was using my typedef this is how it was explained to me and i would be very appreciative if someone would let me know what i'm doing wrong, also this is a partial program i'm not finished with it i just caught the problem and wanted to get it fixed before it got any worse
thanks
//Brandon Curry
/*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>
#include <stdlib.h>
using namespace std;
class WordCount
{
public:
char word[31];
int count;
cout<< "Input file for word count:";
cin>> filename;
inFile.open(filename);
if( inFile.fail() )
{
cout<< "Error could not use this file";
exit(1);
}
else;
while (inFile.peek() != EOF)
{
inFile>>word;
cleanupbegin(word); //gets rid of punctuation
cleanupend(word); //gets rid of punctuation
void store(char word[31], int count, int size, WordEntryList); //store word
}
void store(char word[],int count, int size, WordEntryList myList)
// see I added a name for your variable WordEntryList
{
int found;
char wordFromFile[31];
int n;
// int size; = Don't need this. It's a Parameter
size=0;
n=0;
while ( n<=size && !found)
{
if (strcmp(myList[n].word,word)==0)
found=1;
else;
n++;
}
if (found)
myList[n].count++;
else
{
strcpy(myList[size].word,word);
size++;
}
return;
}
myList is a variable of type WordEntryList. You cannot specify a type, without an instantiated variable.
x[y] = '\0';
This was '/0'; \0 represents NULL. Your typedef statement is fine.