How do i constantly keep checking for specific characters in a text file till there are no more specific characters left.

this way i can keep displaying text file logos on my application until there are none left in the text file being searched by c++ :)

i did have a look around on the string class and f stream but i really don't know what it is i'm so posed to do to achieve the results i'm after.

thank you for taking the time to read this.

5 Years
Discussion Span
Last Post by Lerner

Please be more specific in the description of what you are trying to do. The way I read the first sentence it looks like you want to find a set of characters in a text file, say all the vowels in a piece of text like "eenie meenie minie mo". What that has to do with the second line of the post I don't understand.


thats exactly what i want but i want c++ to constantly look for it till there is no existence of set characters :)

Edited by dakerao: n/a


Start by determining what tools you have available. I believe the STL library has a search function in the string class that allows you to search a given string for a given set of characters, but I don't use the STL extensively so don't quote me. You could use the strtok() function. I know that allows you to perform that type of search. But since I do this for pleasure and not work you could make up your own function like I would.

1)Declare an array to hold all the characters you want to search for.
2)use a nested loop to search each char in the string for each char in the array.
3)If you find on of the search char, do something, otherwise why bother searching.

4)When you can do that for a fixed string allow user to enter string to search and characters to search for.

5)When you can do that then learn how to work with files to read either the entire file at once (if it insn't gargantuan), one line (or some ,other convenient way to define a string, say a paragraph at a time or whatever), or a single char at a time.

6)Once you can read files comfortably, then obtain the material you want from the file in the format you want and apply the search algorithm you have created to do with the file contents what you want.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.