I have a piece of code I'm running in Cygwin in C++ I'm compiling using
g++ -o program program.cpp
And it is returning an error that reads 'Aborted (core dumped)'. It is intended to take a file name as input through a command line argument, count all the unique words and total words in the file, and prompts the user to input a word and counts how many times the word that they input occurs. It's only intended to use C++ streams for input/output.
    #include <fstream>
    #include <iostream>
    #include <string>
    #include <cctype>
    using namespace std; 
    int main(int argc, char *argv[])
    {
        string filename;
        for( int i = 1; i < argc; i++){
            filename+=argv[i];
        }
        ifstream file;
        file.open(filename.c_str());
        if (!file)
        {
            std::cerr << "Error: Cannot open file" << filename << std::endl;
            return 1;
        }
        string* words;
        int* wordCount;
        int wordLength = 0;
        string curWord = "";
        bool isWord;
        int total = 0;
        char curChar;
        string input;
        while(!file.eof())
        {         
            file.get(curChar);
            if (isalnum(curChar)) {
                curWord+=tolower(curChar);
            }
            else if (!curWord.empty() && curChar==' ')
            {
                isWord = false;
                for (int i = 0; i < wordLength; i++) {
                    if (words[i]==curWord) {
                        wordCount[i]++;
                        isWord = true;
                        total++;
                    }
                }
                if (!isWord) {
                    words[wordLength]=curWord;
                    wordLength++;
                    total++;
                }
                curWord="";
            }
        }
        file.close();
        // end
        cout << "The number of words found in the file was " << total << endl;
        cout << "The number of unique words found in the file was " << wordLength << endl;
        cout << "Please enter a word: " << endl;
        cin >> input;
        while (input!="C^") {
            for (int i = 0; i < wordLength; i++) {
                if (words[i]==input) { 
                    cout << wordCount[i];
                }
            }
        }
    }
 
    