Archived

This topic is now archived and is closed to further replies.

Searching/seeking in a text file

This topic is 5180 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heya all. I'm working on a game where I've come the need to have the ability to search in a text file for a specific character, and then have the file pointer point to that character, like oh say the '[' one. I looked into seekg and had really weird results, any suggestions? Sorry if this question has been asked before, but the tutorials over at gametutorials.com didn't seem to have the right answer, and neither did a search over here on the forums. Thanks! [edited by - Enokh on October 10, 2003 8:52:02 PM]

Share this post


Link to post
Share on other sites
Hmm say, wouldn't inputting word by word into strings and checking the first letter of the string be more efficient though than searching char by char?

[edited by - Enokh on October 11, 2003 7:52:14 AM]

Share this post


Link to post
Share on other sites
quote:

Hmm say, wouldn''t inputting word by word into strings and checking the first letter of the string be more efficient though than searching char by char?
[/quote[
It would be less efficient because reading it in a word at a time is basically doing the same thing (reading in 1 char at a time), but it also has to check for whitespace and you have to store the string.

Share this post


Link to post
Share on other sites
About the storing the string part, I''m working through fstream, so fgetc wouldn''t work, I''m just inputting into a char anyway with file_point << CharName.

Share this post


Link to post
Share on other sites