Obtaining the right data from a .txt file

Pages: 12
I found the problem. It was my mistake.

if ( temp.find ( input ) )
should be
if ( temp.find ( input ) != -1 )

Also, line 30 you say 'a' twice.


ps: The find function is case-sensitive. Westside Middle School would be found, but westside middle school would not. Just thought I'd mention it in case you didn't know.
Last edited on
Much thanks, it appears to be working, though I will test it thoroughly tomorrow, and update.
Thanks for your time!

Chf. Os
Last edited on
oh - one last question: how can I arrange the loop so that I can keep inputting names and getting scores until I dont want to anymore more (whereas now after one it will close)?
Put an infinite loop around everything ( while ( true ) ), and right after "Please enter a school name:" check to see if what they entered == exit. You'll want to change "Please enter a school name:" to "Please enter a school name, or enter 'exit' to exit:" as well.
When I do that, it just repeats the same school result over again...how can I stop it after one?

EDIT: I have the loop working correctly now, thanks for the help. There is just one more thing I would like to be able to do. I have it now so that it prints each place won as it goes, and then prints the overall score (I will paste code below). I would also like it to say in which event the place was won in; so it would look like the following:

10th place - Biotechnology Design
1st place - Technology Bowl
3rd Place - Inventions and Innovations
..etc
And then give the total pts.

I have it right now where it prints the places, just not the events too. Somehow, when the program finds the school name and gets the placement, the program will have to know to go "n+2" lines back from the placement (where placement = n) to get the line with event name, since the way the txt file is formatted the event title is "placement + 2" lines back from the placement.

Thanks so much for the help btw
Last edited on
Topic archived. No new replies allowed.
Pages: 12