Hi all, I wrote a program for class that read in a file and counted all occurences of certain key words.
Each line in the file was read one at a time, stored in a temp array and compared to the keywords I had to check for.
The line reading went something like this:
While infile! EOF
{
While infile.get(ch)!='\n'
{ temparray[i]=c; i++;}
....
.....
testing ... etc.
}
It worked for every test file i came up with, however, the teacher has posted the "test file" used for marking it and when i checked it against my program, it CRASHED.
The only reason this happens (or that i can figure out) is because the file has no '\n' null character terminating at the end of each line in the file, causing the temparray to "not" store what is needed.
(is this making any sense).
Just wondering if there was some other way of storing parts of the file to compare to keywords, or if my program was correct in its logic
Any ideas would be appreciated, thanks.
p.s the file to be read was a program file.



LinkBack URL
About LinkBacks



