I'm having a few problems with this, it's a program to get a list of words and have a running total then also sort them different ways. my 1st problem is I'm not sure how to declare my tag when its with one of the words.
problem number 2) is when I compile/run, before i put the swap in, Windows would say there was an error and that it was searching for a solution but it doesn't find any so it closes out my program.
I'd be very appreciative if someone would help me out.
thanks
/*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;
};
typedef WordCount WordEntryList;
void cleanupbegin (char word[31]);
void cleanupend (char word[31]);
int store(char word[31],int& count, WordEntryList[]);
void tagbyletter ( int count, int tag[], WordEntryList[]);
int main ()
{
int i;
int numWords;
int numWordEntries;
char filename[41];
char wordFromFile[31];
char n;
char word[31];
char choice1;
int choice2;
int tag[numWords];
numWords=0;
i=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";
//exit(1);
}
else;
while (inFile.peek() != EOF)
{
inFile>>word;
cleanupbegin(word); //gets rid of punctuation
cleanupend(word); //gets rid of punctuation
store( word, numWords, myList); //store word returns numWords
tagbyletter (numWords, tag, myList);//tag sorts in alphabetical order
}
int main() {
vector<string> vWordList;
vWordList.push_back("hello");
vWordList.push_back("hello");
vWordList.push_back("World");
cout << "Number of words: " << (int)vWordList.size(); << endl;
// This will print out 3
}
well thanks but its for a class and we're not allowed to do it like that, but i still don't understand why the compiler is giving no errors but windows is telling me that its not working right