Hello so hopefuly someone can help me but i cant seem to find the error and my teacher is in Flordia for the next week so i dont have him to ak for help. So my project was to read input from 11 .cpd files one at a time and then do some simple test on them.
These test where to find the average count of: i's, me's, he's, she's, it's, we's, them's, and's, but's, or's, nor's, a's, an's, the's, and proper names.
The Number of: alliterations, and Sentances that start with the same word.
I belive i know where in my program it crashes (between lines 263 and 268) but i can see why. he is my code and a folder with the files and program in it.

https://www.dropbox.com/sh/08sc7hi4dutjuzk/AAA3kQ6apHama0UwmyhdMTaba

    /*///////////////*/
    /* Brennan Flory */
    /*  UHSCSci201N  */
    /*   Gold Team   */
    /*///////////////*/
                                            /*////////////////////////////////*/
    #include <iostream.h>                    /*        activates the bus       */
    #include <conio.h>                       /* activates keyboard and monitor */
    #include <fstream.h>                     /* allows I/O stream flow control */
    #include <iomanip.h>                     /*   setw and other manipulators  */
    #include <string.h>                      /*         string functions       */
    #include <ctype.h>                       /*          char functions        */
    #include <stdlib.h>                      /*        standard functions      */
                                            /*////////////////////////////////*/

    /*//////////////////////////////*/
    /*       File Description       */
    /*   file of words (max=12000)  */
    /* <cr> at end of each sentance */
    /*   <cr><cr> b/t paragraphs    */
    /*//////////////////////////////*/

    void main()
    {
    /*/////////////////////////////////////////////////////////////////////////////////*/

        //Mr. Holdren

        int f;                          // file choice
        char fname[20];                 // fine name

        start:  cout << "\n\n\n\n";       // cycle back to here

        cout << "Available Files\n";
        cout << "  1  itwas2\n";
        cout << "  2  author A, Sample 1\n";
        cout << "  3  author A, Sample 2\n";
        cout << "  4  author B, Sample 1\n";
        cout << "  5  author B, Sample 2\n";
        cout << "  6  author J, Sample 1\n";
        cout << "  7  author J, Sample 2\n";
        cout << "  8  author M, Sample 1\n";
        cout << "  9  author M, Sample 2\n";
        cout << " 10  unknown manuscript\n";
        cout << " 11  test file tfz\n";
        cout << " 12  Done Testing\n\n";
        cout << "Which file? ";
        cin >> f;

        switch(f)
        {
            case 1: strcpy(fname,"itwas2.cpd");break;
            case 2: strcpy(fname,"tfa01.cpd");break;
            case 3: strcpy(fname,"tfa02.cpd");break;
            case 4: strcpy(fname,"tfb01.cpd");break;
            case 5: strcpy(fname,"tfb02.cpd");break;
            case 6: strcpy(fname,"tfj01.cpd");break;
            case 7: strcpy(fname,"tfj02.cpd");break;
            case 8: strcpy(fname,"tfm01.cpd");break;
            case 9: strcpy(fname,"tfm02.cpd");break;
            case 10: strcpy(fname,"unk.cpd");break;
            case 11: strcpy(fname, "unk2.cpd");break;
            case 12: cout << "Tanx and Bye.\n\n"; exit(0); break;
            default: cout << "Not a valid option."; goto start; break;
        }

        cout << "File name: " << fname << endl << endl;     // Just checking....

    /*/////////////////////////////////////////////////////////////////////////////////*/

    //Lembo
        cout<<"Lembo\n\n\n\n";

        cout<<setiosflags(ios::fixed | ios::showpoint);
        cout<<setprecision(2);

    //inputting file and counter stuff
        char cname[70000];
        char wname[12000][20];
        char sname[600][400];
        char wcopy[12000][20];
        int ccount = 0;
        int wcount = 0;
        int scount = 0;
        int ii, jj;

        ifstream fin(fname);
        ifstream fin1(fname);
        ifstream fin2(fname);

        do
        {
            ccount++;
            fin>>cname[ccount];
        }while(!fin.eof());

        do
        {
            wcount++;                                   //point at next word
            fin1>>wname[wcount];                        //get next word
        }while(!fin1.eof());                            //check for eof

        ccount--;                                           //discount eof
        wcount--;                                           //discount eof

        //copying words
        for(ii = 0; ii <= wcount; ii++)
            strcpy(wcopy[ii], wname[ii]);

        do
        {
            scount++;                                       //point at next sentence
            fin2.getline(sname[scount], 400, '\n');         //get next sentence
            fin2.ignore(400, '\n');
            cout<<sname[scount]<<endl;                      // cout<<scount<<endl;
        }while(!fin2.eof());                                //check for eof 

    /*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

    //Flory
        cout<<"Flory\n\n\n\n"<<endl;

        char *token;
        float pro[8];
        float con[5];
        float art[4];
        float prop = 0;
        float allit = 0;
        float sword = 0;
        char fword[600][20];
        char maxword[50];
        int cmaxnum; 
        int maxnum = -99999;
        char wtemp[20];
        char curword[20];

        //Poronouns
        pro[1] = 0.0;
        pro[2] = 0.0;
        pro[3] = 0.0;
        pro[4] = 0.0;
        pro[5] = 0.0;
        pro[6] = 0.0;
        pro[7] = 0.0;

        for(ii = 1; ii <= wcount; ii++)
            strlwr(wcopy[ii]);
        //i
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "i") == 0)
                pro[1]++;
        }

        //me
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "me") == 0)
                pro[2]++;
        }

        //he
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "he") == 0)
                pro[3]++;
        }

        //she
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "she") == 0)
                pro[4]++;
        }

        //it
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "it") == 0)
                pro[5]++;
        }

        //we
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "we") == 0)
                pro[6]++;
        }

        //them
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "them") == 0)
                pro[7]++;
        }

        //Conjuctions
        for(ii = 1; ii <= 4; ii++)
            con[ii] = 0;


        //and
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "and") == 0)
                con[1]++;
        }

        //but
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "but") == 0)
                con[2]++;
        }

        //or
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "or") == 0)
                con[3]++;
        }

        //nor
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "nor") == 0)
                con[4]++;
        }

        //Articles
        for(ii = 1; ii <= 3; ii++)
            art[ii] = 0;

        //a
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "a") == 0)
                art[1]++;
        }

        //an
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "an") == 0)
                art[2]++;
        }

        //the
        for(ii = 1; ii <= wcount; ii++)
        {
            if(strcmp(wcopy[ii], "the") == 0)
                art[3]++;
        }

        //Proper names
        for(ii = 1; ii <= wcount; ii++)
        {
            if(isupper(wname[ii][0]) != 0) 
                prop++;
        }

        //sentances with same word
        for(ii = 1; ii <= scount; ii++)
        {
            token = strtok(sname[ii], " ");
            strcpy(fword[ii], token);
            cout<<fword[ii]<<endl;
        }

        for(ii = 1; ii <= scount - 1; ii++)
        {
            for(jj = 1; jj <= scount; jj++)
                if(stricmp(fword[ii], fword[jj]) == -1)
                {
                    strcpy(wtemp, fword[ii]);
                    strcpy(fword[ii], fword[jj]);
                    strcpy(fword[jj], wtemp);
                }
        }
        cout<<scount<<endl;

        cmaxnum = 0;
        for(ii = 1; ii <= scount - 1; ii++)
        {
            for(jj = 1; jj <= scount; jj++)
            {
                if(stricmp(fword[ii], fword[jj]) == 0)
                {
                    strcpy(curword, fword[ii]);
                    cmaxnum++;
                    if(cmaxnum > maxnum)
                    {
                        maxnum = cmaxnum;
                        strcpy(maxword, fword[ii]);
                    }
                }   
            }
        }

        //alliterations
        for(ii = 0; ii <= wcount - 1; ii++)
        {
            jj++;
            if(wcopy[ii][0] == wcopy[jj][0])
                allit++;
        }
        cout<<allit<<endl;

        //%'s
        pro[1] = (pro[1] * 1.0 / wcount) * 100;
        pro[2] = (pro[2] * 1.0 / wcount) * 100;
        pro[3] = (pro[3] * 1.0 / wcount) * 100;
        pro[4] = (pro[4] * 1.0 / wcount) * 100;
        pro[5] = (pro[5] * 1.0 / wcount) * 100;
        pro[6] = (pro[6] * 1.0 / wcount) * 100;
        pro[7] = (pro[7] * 1.0 / wcount) * 100;

        con[1] = (1.0 * con[1] / wcount) * 100;
        con[2] = (1.0 * con[2] / wcount) * 100;
        con[3] = (1.0 * con[3] / wcount) * 100;
        con[4] = (1.0 * con[4] / wcount) * 100;

        art[1] = (1.0 * art[1] / wcount) * 100;
        art[2] = (1.0 * art[2] / wcount) * 100;
        art[3] = (1.0 * art[3] / wcount) * 100;

        prop = (1.0 * prop / wcount) * 100;

        sword = (1.0 * maxnum / wcount) * 100;

        //Showing Data
        cout<<"\nCount of 'I's: "<<pro[1];
        cout<<"\nCount of 'Me's: "<<pro[2];
        cout<<"\nCount of 'He's: "<<pro[3];
        cout<<"\nCount of 'It's: "<<pro[5];
        cout<<"\nCount of 'We's: "<<pro[6];
        cout<<"\nCount of 'She's: "<<pro[4];
        cout<<"\nCount of 'Them's: "<<pro[7];

        cout<<"\nCount of 'And's: "<<con[1];
        cout<<"\nCount of 'But's: "<<con[2];
        cout<<"\nCount of 'Or's: "<<con[3];
        cout<<"\nCount of 'Nor's: "<<con[4];

        cout<<"\nCount of 'A's: "<<art[1];
        cout<<"\nCount of 'An's: "<<art[2];
        cout<<"\nCount of 'The's: "<<art[3];

        cout<<"\nPrecentage of Proper Names: "<<prop;

        cout<<"\nMost seen word was '"<<maxword<<"' seen (%): "<<sword;

        cout<<"\nNumber of Alliterations: "<<allit;
    }

Thank you for your help.

I've just skimmed through your code, and theres some problems.

First off it's interesting to note that "Brennan Flory" and "Michael Leto" apperently have identical code, other then the names on top.

Second, you don't need to have the ".h" at the end of your includes.

Down to your second line of code, #include <conio.h> is not a well supported library. If you really need that kind of functionality, there are better libraries for you. Furthermore, I don't even see you using anything it provides anyways.

Next off, don't define main as void main(). It's int main(). I hope your teacher didn't teach you that.

Next, Break down your code into smaller functions. It makes your code much easier to read, and it'll probably make something like this a lot shorter too.

You'll probably find it easier to use std::string instead of c-strings.

Instead of having a loop for each word, loop though the words once, and enlongate your if statement. For example:

 for(ii = 1; ii <= wcount; ii++)
 {
    if (strcmp(wcopy[ii], "i") == 0)
        pro[1]++;
    else if(strcmp(wcopy[ii], "he") == 0)
        pro[2]++;
    else if(strcmp(wcopy[ii], "she") == 0)
        pro[3]++;
    ...
}

That will make your program much shorter and several times faster.

As you your crash, you should tell us why it crashed (the errors it spits out).

Thank you sir for these helpful tibbits, but this still doesn't help me with my problem. The problem is, is that it is crashing during run time and not giving me any errors so i dont know what the problem is. As for my techniques my teacher taught our whole class to program that way and wants us to continue that way.

Another problem is line 87 should be std::ifstream fin(fname);. Same goes for lines 88 and 89. If you combine my last post with this one, your program will actually compile on a standard c++ compiler.

When I ran it, I noticed that your program printed out a lot of whitespace before crashing. That's why you didn't see anything. Examining the output more closly reveiled that your program did print out the file. But it never printed out the word "Flory". Thus, your program crashed somewhere in lines 110 to 116. Now, since it printed out a lot of whitespace, I suspect that is from your loop not stopping, and reading memory that it's not supposed to be accesing.

That should give you enough information to get somewhere.

As for my techniques my teacher taught our whole class to program that way and wants us to continue that way.

Well, there isn't much we can do about bad teachers. Do whatever makes your teacher happy. What are you using, Turbo C++? That belongs 20 years in the past. If your paying for your education, you could consider writting a complaint to the department. I would suggest that you pick up a book, and learn proper C++ if you think you will need to use it in real life.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.