My name is Hitesh Khurana, let me get straight to the point.
I am working on homework for my programming class;however, I keep running into a problem when running my program.
The problem given to the students as the assignment is:
We need to create a program that reads a text file and counts the characters in each line. The program should display the line number and the length of the shortest and longest lines in the file, as well as the average number of characters per line.
Now here is what my problem is.
When I run my program what happens is, that it keeps running. i have tried several compilers and it just never stops looking inside a 3 character text file
(for test purposes). Here is the code feel free to correct any problem that I may have , but please reply ASAP.
NOTE: I have copied this code from the textbook just to see troubleshoot my coding. Now when you compile this the textfile I use is called test.txt
it contains 3 characters 'thi' (without the single quotes) and is located in the same directory as the cpp code the program just keeps running, it is really frustrating lol. Solved so removed for stopping plagirism reasons ;)
P.S. I have searched on google but no help :(. If you would like to know the textbook the isbn is 0131409093.
reading is of type double. You're trying to read letters into a variable of type double. This puts the input stream (fin in this case) into a fail state. Since you don't check the state of the stream other than whether it's hit eof, your loop never exits.