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.
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?
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
Program-5.cpp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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...
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.
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;
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.