In my program, I have to input a word and then a character. The program will tell me how many times does the character appear in the word...my problem is that I have to find this character with the find(str,ind)...I know the ind is the index and can be manipulated with a loop...but what about the "str" part of it? I know that's where the character should be, so can I put the name of the variable in which the char is stored?
J.Killa
0
Light Poster
Recommended Answers
Jump to PostDon't you mean you need to use std::string's find() method? e.g.
std::string word = "Hello"; size_t pos = word.find('.', 0);
In the above, just put it in a loop and replace the second parameter to find() with the variable pos that was returned by the previous find. …
All 3 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
J.Killa
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.