Link to home
Start Free TrialLog in
Avatar of Big_Dlee
Big_Dlee

asked on

C++ program counting letters

need help with a program that counts number of times a letter occurs in a line from a file. using nested for loops with a switch inside the for loops.
Avatar of mccarl
mccarl
Flag of Australia image

Welcome to EE! I realise that you are new here, but you have to give us something to go on, to be able to help you. Can you post the code and detail what you need help with? Is it not compiling, is it giving an error or does it just not do what you are expecting?
Avatar of Big_Dlee
Big_Dlee

ASKER

not doing what it should im trying to count the number of times a character occurs in a line using a nested for loop with a switch inside. this is what i have so far.
Program-5.cpp
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK thanks it really helped now the only problem is i need to count characters for each line and total for that specific line not keep it running through the whole file. how can i reset it after each line?
Put in another case block, such as...

case 0x13:
case 0x10:
    // Statements to print out the current lines counts
    //

    // Reset the counters ready for the next line
    CountA = 0;
    CountB = 0;
    // Etc, for all the other counts
    //
    break;

Open in new window


Obviously, this doesn't line up with using the for loop to count through lines, but the way you are reading from the files means that you CAN'T use a for loop for that, you would have to change most of the structure of the program to use a for loop properly. Same goes for the "Letter" for loop to, actually.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.