Hello there,
Okay well i have tried to do this program but i'm just not sure if i'm going in the right direction. Well i have to create a text file (Did that) which is inputed into the program, and the program has to count the instances of the following categories of symbols. such as Uppercase and lower case letters, digits, End of sentence markers like periods, question marks, and explanation points, also commas, semicolons, and colons, and Blanks. Okay well i have written some code and i used a switch statement in my processing. but the thing is, i'm not sure if i'm doing it right. And after all these satistics, i have to use them to approximate the average word and sentence length.I need another's help on this if you would, i'd be greatful for your help or for anything. Well happy holidays and thanks for your time.

make a seperate counter for each instance
read the file 1 character at a time
for the upperccase and lowercase you can use the functions isupper and islower and whenever the return is 1 incriment the respective counters as for the other instances, use the ascii values of the characters

You can do somthing like this:

#include <iostream>
using namespace std;
int main()
{
    char test[] = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.!:;? ";// all the chars you are testing for
    int size = sizeof(test)/sizeof (char); // size of test array
    int counter[size]; // make array of int's
    string s1;
    cout << "enter stringn";
    cin >> s1; // get string

    for(int i = 0; size > i; i++)
    { // rest all of counter to 0
        counter[i] = 0;
    }

    for (int i = 0; s1[i] != '\0'; i++) // loop theu the s1 string
    {
        for(int j = 0; size > j; j++)
        {
            if (s1[i] == test[j]) // check if it match
            {
                counter[j]++; // if, the add one to the right counter
            }
        }
    }

    for(int i = 0; size > i; i++)
    { // cout all the letters, and the frequency
        cout << test[i] << " : " << counter[i] << 'n';
    }
}

just need to change it to get the input from a fil instead of screan :)

Nice. :-)

well... all symbols are assigned from 0 to 255... why not create an array of counter which count the number of ascii value which is the same as it index.. and in the same time the index is the ascii value of the symbol counted.... my algo for that ...^___^ hehe...

#include<string.h>
#include<stdio.h>
main()
{
char buffer[1000] = "series of text input from file...";
/* assuming u know how to get the content of the file and then store it into a buffer data (example buffer[1000] ) 100 characters */

int counter[256]; /* counter for each ascii or symbol */

for(x=0;x<255;x++){
counter[x]=0; /* initialize all to zero..*/
}

for(y=0;y<strlen(string);y++){
ascii_value = buffer[y];
counter[ascii_value] ++;
}

/*displaying the result..
for(z=0;z<255;z++){
printf("%c = %d ",z, counter[z]);
}
getch();
}

any clarification <<email snipped>>
those code are in C anyways.. c and c++ are much
alike.. so just code it to c++ base on my posted code if
u have understood it...
;)

ivanCeras plz use code tags.

Let sleeping threads lie.

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.